openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Curtis <curti...@gmail.com>
Subject Re: did pass params - Attempt to insert null into a non-nullable column
Date Wed, 01 Jul 2009 18:31:11 GMT
John -

It looks like you annotated your Person.id to be unique, but you didn't
specify a value... I'm assuming that you're using an AI column for your id.
I see you're running on MySQL, so try adding the annotation
@GeneratedValue(strategy=GenerationType.IDENTITY) to your id column. If that
doesn't work, please post a snippet of your Entity/mapping file(s).

-Rick

On Wed, Jul 1, 2009 at 12:44 PM, John_canada <john_woo@canada.com> wrote:

>
> Hi,
>
> I deployed openejb.war in tomcat, and tested a web app which used ejb3;
> it's
> very simple: a servlet called a stateless bean, which created an entity as
> following:
>
> session bean:
> @PersistenceContext(unitName="aUnit",type =
> PersistenceContextType.TRANSACTION)
> private EntityManager manager;
>
> Person p = new Person(name, address);
> manager.persist(p);
> manager.flush();
>
> the persistence.xml:
> <persistence-unit name="aUnit" transaction-type="JTA">
>
>  <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>        <jta-data-source>myTX</jta-data-source>
>        <non-jta-data-source>myNOTX</non-jta-data-source>
>        <class>ejb.Person</class>
>  ...
>
> openejb.xml:
>        <Resource id="myTX" type="DataSource">
>                JdbcDriver com.mysql.jdbc.Driver
>                JdbcUrl jdbc:mysql://localhost:3306/a
>                UserName root
>                Password aaa
>        </Resource>
>
>        <Resource id="myNOTX" type="DataSource">
>                JdbcDriver com.mysql.jdbc.Driver
>                JdbcUrl jdbc:mysql://localhost:3306/a
>                UserName root
>                Password aaa
>                JtaManaged false
>        </Resource>
>
> However, I got the following error when executing manager.flush();
> org.apache.openjpa.lib.jdbc.ReportingSQLException: Attempt to insert null
> into a non-nullable column: column: ID table: PERSON in statement [INSERT
> INTO person (person_id, address, name) VALUES (?, ?, ?)] {prepstmnt 6240623
> INSERT INTO person (person_id, address, name)
>    VALUES (?, ?, ?)
> [params=(long) 2201, (String) any address, (String) name]} [code=-10,
> state=23000]
>
>
> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:192)
>
>
> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$700(LoggingConnectionDecorator.java:57)
>
>
> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:866)
>
>
> org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:269)
>
>
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeUpdate(JDBCStoreManager.java:1504)
>
>
> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.executeUpdate(PreparedStatementManagerImpl.java:151)
>
>
> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:120)
>
>
> org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushAndUpdate(BatchingPreparedStatementManagerImpl.java:82)
>
>
> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:89)
>
>
> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush(PreparedStatementManagerImpl.java:72)
>
>
> org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:543)
>
>
> org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:105)
>
>
> org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.flush(BatchingConstraintUpdateManager.java:59)
>
>
> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:89)
>
>
> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:72)
>
>
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:655)
>
>
> org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:130)
>        org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2010)
>        org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1908)
>        org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1679)
>
>  org.apache.openjpa.kernel.DelegatingBroker.flush(DelegatingBroker.java:989)
>
>
> org.apache.openjpa.persistence.EntityManagerImpl.flush(EntityManagerImpl.java:592)
>
>
> org.apache.openejb.persistence.JtaEntityManager.flush(JtaEntityManager.java:130)
>        ejb.HelloBean.createPerson(HelloBean.java:31)
>        sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        java.lang.reflect.Method.invoke(Method.java:597)
>
>
> org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:158)
>
>
> org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:141)
>
>
> org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:122)
>
>
> org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:221)
>
>
> org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:174)
>
>
> org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:217)
>
>
> org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:77)
>
>
> org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:281)
>        $Proxy46.createPerson(Unknown Source)
>        test.HelloServlet.doGet(HelloServlet.java:31)
>        javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
>        javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>
>
> It's obvious, from
> INSERT INTO person (person_id, address, name)
>    VALUES (?, ?, ?)
> [params=(long) 2201, (String) any address, (String) name]} [code=-10,
> state=23000]
>
> the parms values were taken, but did not pass/forward to database - this
> should not be in ejb3 package.
>
> Can anyone tell how to fix it?
>
> Thanks
> --
> John
> --
> View this message in context:
> http://n2.nabble.com/did-pass-params---Attempt-to-insert-null-into-a-non-nullable-column-tp3190581p3190581.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message