-
1. Re: CMP 2.0 not populating foreign key field for many to one
jbossuser Dec 15, 2001 10:10 PM (in response to jbossuser)If anyone was interested, turns out it was because the insert contained a blob. When I removed that field, the foreign key was properly updated.
-
2. Re: CMP 2.0 not populating foreign key field for many to one
kleku Jul 6, 2003 1:47 PM (in response to jbossuser)Hi,
I think it's a bug (quite serious)
3.2.1, mysql, connector 3.0.8
these are code fragments from ProductPriceEjb bean:
public Long ejbCreate(ProductLocal product, Price price) throws CreateException {
setValue(price.getPrice().getValue());//just a BigDecimal value (pk is auto-incremented)
return null;
}
public void ejbPostCreate(ProductLocal product, Price price) {
if (product == null) {//just to be sure
throw new EJBException();
}
setProduct(product);
}
public void ejbStore() {
System.out.println("Store: " + getProduct().getPrimaryKey());
//throws NPE but only if create is called more than once (after second create)
}
Bye -
3. Re: CMP 2.0 not populating foreign key field for many to one
kleku Jul 6, 2003 1:49 PM (in response to jbossuser)I just forgot to mention - no blobs
-
4. Re: CMP 2.0 not populating foreign key field for many to one
thuesler Jul 8, 2003 5:11 AM (in response to jbossuser)Hi all
I am actually experiencing the same problem. (find detailed scenario description at end of mail).
When I was debugging I figured out that the sql insert call is already executed after ejbCreate and not after ejbPostCreate. When then looking into the sql param / statement I saw that it contains my foreign key field in the statement but of course the param value is not set yet...
When I place a breakpoint in ejbPostCreate it even never holds (now this does not mean too much, but get worried about that)...
I would really appreciate any help for that. At the moment I get the pk key value from the passed in parent obj reference and set it already in ejb create and again set in post create the reference itself...
BTW I am not using any blobs or anything...
Please help!
Tom
Scenario:
- Table Person (PK int, Name, first)
- Table Contract (PK int, PersonFK int)
- Relationship between contract and person (bidirectional) 1 Person may have many contracts
- PersonFK in Table contract has a not null criteria defined in db
- IBM DB2 running on Mainframe
- JBoss 3.2.1 used -
5. Re: CMP 2.0 not populating foreign key field for many to one
viz Jul 8, 2003 4:05 PM (in response to jbossuser)I think there is a bug: JBoss 3.2.1, mySQL, 3.0.8 connector.
I had two tables (Customer and Address) both using AUTO_INCREMENT. Although rows were created JBoss seemed unable to create the relationship between them (1-2-1).
I went back to took a look at the Customer bean and discovered that JBoss does not seem to like AUTO_INCREMENT on the PK. If I call create() - without PK as this is AUTO_INCREMENT - the row is created, but try remove() (or findByPrimaryKey(...) and JBoss throws an error:
java.lang.IllegalArgumentException: Attempt to get lock ref with a null object
Now, I'm not sure if this is related?
Any help gratefully received.
--
Marc -
6. Re: CMP 2.0 not populating foreign key field for many to one
sreram Jul 14, 2003 3:56 AM (in response to jbossuser)I am facing the same problem in jboss 3.2.1 version. I have a master table. this table has some set of attributes(CMR) which needs to be inserted in the detail table(related table). I am getting a "dulicate column name " error. but the entity is getting created for master table.
I tried with <foreign-key-mapping /> tag.
I tried with <relation-table-mappting > tag.
I tried with tag.
nothing seems to work. I suspect it is either bug or descriptor is wrong.
have any tried to insert master-detail table with CMR using JBoss. if so please suggest me what is wrong.