users@glassfish.java.net

Toplink nulls fields that contain data

From: <glassfish_at_javadesktop.org>
Date: Tue, 11 Sep 2007 07:32:21 PDT

Hi, I have the following problem:

Internal Exception: java.sql.SQLException: Column 'user_id' cannot be nullError Code: 1048
Call:INSERT INTO EXPRESSION (EXPRESSION_ID, CONTEXT, NAME, BODY, VERSION, RETURNVALUE_PARAMETER_ID, NEWERVERSION_EXPRE
SSION_ID, OLDERVERSION_EXPRESSION_ID, user_id, DTYPE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
        bind => [454, null, null, null, 0, null, null, null, null, OclQuery]

Now the thing is, almost none of these fields are null. content, name, body and version are normal Strings or a long, so just @Basic so-to-say even. And I went to debug-mode, just to see that they really ARE there.
Can anybody give me a hint on what could be a possible reason why Toplink sets them to null?

The object that I want to persist is "OclQuery" which extends my class "Expression". The makePersistent(..) of my DAO:
EntityManager em = getEntityManager();
                try {
                        utx.begin();
                        entity=em.merge(entity);
                        em.persist(entity);
                        utx.commit();
...

utx is the UserTransaction.

I also have to say, usually it works just fine, but in a few cases it does not and I really don't know whats going on. I.e. yesterday I tried to find out whats going wrong for 4 hours, then it suddenly worked and I was happy. Today I wanted to continue, and ... the old problem was suddenly back, even before I had made any changes.
[Message sent by forum member 'david1' (david1)]

http://forums.java.net/jive/thread.jspa?messageID=234862