did you tried
broker.beginTransaction(); broker.store( user );
// userLoginBean.setUserID( user.getUserID() ); userLoginBean.setInfoID(user.getUserID()); set the FK-field of LoginBean not the PK-field.
or if you use an anomymous field-descriptor for the fk field-descriptor
userLoginBean.setUserInfoBean(UserInfoBean info); (maybe you have to set the UserInfoBean in any case)
broker.store( userLoginBean ); broker.commitTransaction();
By the way, why don't you let OJB do the job and set 'auto-update' true in reference-descriptor?
info = *get UserInfoBean instance* userLoginBean.setUserInfoBean(info); broker.beginTransaction(); broker.store( userLoginBean ); broker.commitTransaction();
Think 1:1 and 1:n references definitely work, because in OJB test suite you can find test cases using this features and all tests pass.
regards, Armin
Robert S. Sfeir wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Armin Waibel wrote:
| Hi again, | | Robert S. Sfeir wrote: | | Thanks for the notes, I am not entirely sure what the info_id is. Can | you explain? How is that any different from the userID I use as a | foreign key? | |> you define a 1:1 reference from UserLoginBean to UserInfoBean, thus |> you need a FK to UserInfoBean. If you only set 'userId' then the |> reference-descriptor assume userId field-descriptor of UserLoginBean |> is the FK to UserInfoBean !? |> Thus you need an additional FLD.
In my table user_info.user_id is a foreign key reference to user_login.user_id.
Anyway, I took your suggestion, read the page, and implemented the changes and the error is the same in the end.
This is the exception, however when I print userID from the UserInfoBean.getUserID() I get "User ID IS: 10345". The user id is in fact NOT null, but the insert says it is.
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: SQLException
during the execution of the insert (for a
com.codepuccino.security.beans.UserLoginBean): General error, message
from server: "Column 'user_id' cannot be null"
General error, message from server: "Column 'user_id' cannot be null"
java.sql.SQLException: General error, message from server: "Column
'user_id' cannot be null"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1825)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1020)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1109)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2030)
at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1750)
at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1596)
at
org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeInsert(Unknown
Source)
at org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(Unknown
Source)
at org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown Source)
at org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown Source)
at org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(Unknown
Source)
at org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(Unknown
Source)
at
com.codepuccino.security.sql.ojb.RegistrationDAOImpl.addRegistration(RegistrationDAOImpl.java:158)
at
com.codepuccino.security.actions.RegistrationAction.execute(RegistrationAction.java:109)
at
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:284)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:563)
at
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:245)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:199)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:563)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:195)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:563)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:156)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:563)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:209)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:549)
at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:589)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:666)
at java.lang.Thread.run(Thread.java:534) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE/uinl+cV9vuB27SARAvuZAKCcX4sCK3UMJAm+oM1Z7xdhwzLrUgCg0NOl m1QrQAHUREIIpoLN2PjNkhI= =YkRs -----END PGP SIGNATURE-----
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
