I have a bean using a dependent value class that is mapped to several columns in the same table as the bean. I followed the example in the official $10 cmp docs in the DVC chapter, where the DVC is mapped to columns in jbosscmp-jdbc.xml.
There are two problems I have run across (using 1 hr. old CVS jboss):
1) If every column used by the DVC is null, a call on getMyDVC() (abstract accessor method in the bean) returns null. Therefore, I cannot retrieve a DVC instance to edit. I'm not sure if this is a usage error or a bug, but I would think that it should return a valid object with each internal field being null. I then have to create my own DVC instance before using the corresponding setMyDVC() method in order to set values in the DVC columns. This isn't a big deal though. However, that brings me to (2):
2) If I set a DVC column in the database by hand (leaving the others null), JBoss attempts to load the DVC but gets the error named in the subject:
12:49:48,514 ERROR [STDERR] javax.ejb.EJBException: Error setting column value
followed by a lengthy stack trace, of which the first few lines are:
12:49:48,514 ERROR [STDERR] at org.jboss.ejb.plugins.cmp.jdbc.JDBCTypeComplex.setColumnValue(JDBCTypeComplex.java:161)
12:49:48,515 ERROR [STDERR] at org.jboss.ejb.plugins.cmp.jdbc.JDBCTypeComplex.setColumnValue(JDBCTypeComplex.java:133)
12:49:48,525 ERROR [STDERR] at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.loadArgumentResults(JDBCAbstractCMPFieldBridge.java:352)
12:49:48,527 ERROR [STDERR] at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.loadInstanceResults(JDBCAbstractCMPFieldBridge.java:304)
I'm not sure this is a usage error, but it is related to (1) since JBoss seems to be trying to read values from the other columns which contain null values (which seems to be the reason the null DVC object is returned previously)
The only way I can successfully persist the DVC value(s) is if I create my own DVC instance, use setMyDVC() , then use getMyDVC() , which creates a valid DVC object with the appropriate fields initialized.
Am I required to create an empty DVC instance and call setMyDVC() during the ejbCreate method of the parent entity bean?
(I am using Postgres 7.2 and their latest JDBC driver - perhaps this problem may be due to the way postgres seems to treat empty column values differently than null values?)
Any thoughts on this?
Thanks in advance.