problem for 2nd table using CMP
madadi Jun 16, 2004 10:14 AMDear all,
i am using jboss_3.2.1 and mysql-4.0.18 .as i am new to j2ee iam getting different type of errors.
my database contains 2 tables.personal_data and specific_data.
personal_data look like...
mysql> describe personal_data;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| userid | varchar(30) | | PRI | | |
| fname | varchar(20) | YES | | NULL | |
| lname | varchar(20) | YES | | NULL | |
| dob | varchar(10) | YES | | NULL | |
| sex | varchar(10) | YES | | NULL | |
| password | varchar(30) | YES | | NULL | |
| street | varchar(30) | YES | | NULL | |
| city | varchar(30) | YES | | NULL | |
| zipc | int(20) | YES | | NULL | |
| phone | int(25) | YES | | NULL | |
| email | varchar(30) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
table specific_data look like...
mysql> describe specific_data;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| userid | varchar(30) | | MUL | | |
| dept | varchar(30) | YES | | NULL | |
| mno | int(20) | YES | | NULL | |
| sem | int(5) | | PRI | 0 | |
+--------+-------------+------+-----+---------+-------+
both contains userid which is PRIMARY KEY for personal_data and FOREIGN KEY for specific_data.
i wrote a CMP for personal_data it works fine but for specific_data error occurs saying...
15:33:43,990 ERROR [RegistrationspecificEjb] Could not create entity
java.sql.SQLException: General error, message from server: "Column 'userid' can
not be null"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1905)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1109)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1203)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2090)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java
:1680)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java
:1527)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdat
e(WrappedPreparedStatement.java:308)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.insertEntity(J
DBCCreateEntityCommand.java:321)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.execute(JDBCCr
eateEntityCommand.java:209)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStor
eManager.java:569)
at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersisten
ceManager.java:225)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.crea
teEntity(CachedConnectionInterceptor.java:270)
at org.jboss.ejb.EntityContainer.createHome(EntityContainer.java:725)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityC
ontainer.java:998)
at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractIntercep
tor.java:88)
at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(Ent
itySynchronizationInterceptor.java:188)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invo
keHome(CachedConnectionInterceptor.java:215)
at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractIntercep
tor.java:88)
at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInst
anceInterceptor.java:91)
at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInte
rceptor.java:61)
at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCrea
tionInterceptor.java:28)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInte
rceptor.java:88)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxIntercep
torCMT.java:273)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.ja
va:74)
at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityIntercep
tor.java:92)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:1
20)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyF
actoryFinderInterceptor.java:93)
at org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java
:477)
at org.jboss.ejb.Container.invoke(Container.java:694)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBea
nDispatcher.java:284)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:101)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.jav
a:83)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.
java:46)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:4
5)
at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:173)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
at $Proxy52.create(Unknown Source)
at madadi.entity.RegistrationspecificClient.doGet(RegistrationspecificCl
ient.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:360
)
at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicati
onHandler.java:294)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:5
58)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1714)
at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplication
Context.java:507)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1664)
at org.mortbay.http.HttpServer.service(HttpServer.java:863)
at org.jboss.jetty.Jetty.service(Jetty.java:460)
at org.mortbay.http.HttpConnection.service(HttpConnection.java:775)
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:939)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:792)
at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:
201)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:455)
is there any problem with PRIMARY and FOREIGN KEY relation ship ? in ejb-jar.xml i wrote like this ...
<ejb-ql><![CDATA[SELECT OBJECT(pdata) FROM Registration as pdata]]></ejb-ql>
for specific_data table also i wrote..
<ejb-ql><![CDATA[SELECT OBJECT(sdata) FROM Registrationspecific as sdata]]></ejb-ql>
information needed...............Thanking you in advance............
regards
madadi