On to the second issue:

>>2) Build a message with multiple addressees.  I try to save the message
and
>>get a "com.sybase.jdbc2.jdbc.SybBatchUpdateException: JZ0BE:
>>BatchUpdateException: Error occurred while executing batch statement: ASA
>>Error -143: Column '@p1' not found" SQL Exception.  Here is the SQL:

>Ah. interesting. My Sybase install broke a while back so I didn't get a
>chance to test its JDBC2 compliance. I imagine that setting
>
>hibernate.use_jdbc2=false

I tried that and the same problem happened.  I'm using the JConnect 5.5
driver which claims to be JDBC2 compliant.

>Actually, just for an experiment ... could you
>please try using a vm.long style id generation and see if you recieve the
>same exception? (just to rule out the possibility that native keygeneration
>has anything to do with it....)

That also had no effect.

I had worked around the problem by manually loading and saving the
MessageAddressee collection.  When I put things back, I still got an
exception saving, but it was a bit different (Ugh).  I've attached the
source and TRACE below.

Sorry I didn't get back to you right away.  I've been dealing with some
other issues.

Regards,
John

--------------------------------------------------

Here's the code where I save a message:

try {
        
        // get the sender
        Staff staff = aMessage.getSender();
        session.update(staff);
        
        // get the message boxes
        List boxes = session.find(
                "select box " +
                "  from box " +
                "    in class domain.MessageBox" +
                "  order by box.id");

        // add the message to each addressees' mailbox
        List newEntries = new ArrayList();
        for (Iterator i = aMessage.getAddressees().iterator(); i.hasNext();
) {
                Addressee addressee = (Addressee)i.next();
                
                // the group was loaded in another session
                if (addressee.isGroup()) {
                        session.update(addressee);
                }
                
                Collection recipients = addressee.getStaffEntries();
                for (Iterator r = recipients.iterator(); r.hasNext(); ) {
                        
                        Staff recipient = (Staff)r.next();
                        session.update(recipient);
                        
                        MessageBoxEntry newEntry = new MessageBoxEntry();
                        newEntry.setMessage(aMessage);
                        newEntry.setMessageBox((MessageBox)boxes.get(0));
                        newEntry.setStaff(recipient);
                        
                        newEntries.add(newEntry);
                }
                
        }

        // add the message to the sender's mailbox
        MessageBoxEntry sentEntry = new MessageBoxEntry();
        sentEntry.setMessage(aMessage);
        sentEntry.setMessageBox((MessageBox)boxes.get(1));
        sentEntry.setStaff(staff);

        // save the message
        aMessage.setDateSent(new Date());
        session.save(aMessage);
        
        // add entries
        for (Iterator i = newEntries.iterator(); i.hasNext(); ) {
                session.save(i.next());
        }
        session.save(sentEntry);

        session.flush();
        
} finally {
        session.close();
}

Here's the TRACE of this portion of the code:

7625 [main] DEBUG
<cirrus.hibernate.connection.DriverManagerConnectionProvider> Using cached
JDBC connection
7625 [main] DEBUG <cirrus.hibernate.impl.SessionImpl> opened session
7625 [main] DEBUG <cirrus.hibernate.impl.SessionImpl> updating
domain.StaffImpl#49
7625 [main] DEBUG <cirrus.hibernate.impl.SessionImpl> find: select box
from box     in class domain.MessageBox  order by box.id
7625 [main] DEBUG <cirrus.hibernate.query.QueryTranslator> compiling query
7625 [main] DEBUG <cirrus.hibernate.impl.SessionImpl> flushing session
7640 [main] DEBUG <cirrus.hibernate.impl.SessionImpl> Updating entity:
domain.StaffImpl#49
7640 [main] DEBUG <cirrus.hibernate.impl.SessionImpl> Flushing: 0
insertions, 1 updates, 0 deletions to 1 objects
7640 [main] DEBUG <cirrus.hibernate.impl.SessionImpl> Flushing: 0
insertions, 0 updates, 0 deletions to 0 collections
7640 [main] DEBUG <cirrus.hibernate.query.QueryTranslator> HQL: select box
from box     in class domain.MessageBox  order by box.id
7640 [main] DEBUG <cirrus.hibernate.query.QueryTranslator> SQL: SELECT
box.id, box.description FROM message_box box ORDER BY  box.id
7640 [main] DEBUG <cirrus.hibernate.impl.SessionFactoryImpl> prepared
statement get: SELECT box.id, box.description FROM message_box box ORDER BY
box.id
Hibernate: SELECT box.id, box.description FROM message_box box ORDER BY
box.id
7640 [main] DEBUG <cirrus.hibernate.ps.PreparedStatementCache> Preparing
statement: SELECT box.id, box.description FROM message_box box ORDER BY
box.id
7640 [main] DEBUG <cirrus.hibernate.impl.SessionImpl> Initializing object
from ResultSet: 1
7640 [main] DEBUG <cirrus.hibernate.impl.ClassPersister> Hydrating entity:
domain.MessageBox#1
7656 [main] DEBUG <cirrus.hibernate.impl.SessionImpl> Initializing object
from ResultSet: 2
7656 [main] DEBUG <cirrus.hibernate.impl.ClassPersister> Hydrating entity:
domain.MessageBox#2
7656 [main] DEBUG <cirrus.hibernate.ps.PreparedStatementCache> recaching
7656 [main] DEBUG <cirrus.hibernate.impl.SessionImpl> updating
domain.StaffImpl#45
7656 [main] DEBUG <cirrus.hibernate.impl.SessionImpl> updating
domain.StaffImpl#49
7656 [main] DEBUG <cirrus.hibernate.impl.SessionImpl> updating
domain.StaffImpl#1
7656 [main] DEBUG <cirrus.hibernate.impl.SessionImpl> saving
domain.Message#native
7656 [main] DEBUG <cirrus.hibernate.impl.ClassPersister> Inserting entity:
domain.Message (native id)
7656 [main] DEBUG <cirrus.hibernate.impl.ClassPersister> Inserting entity:
domain.Message#null
7656 [main] DEBUG <cirrus.hibernate.impl.SessionFactoryImpl> prepared
statement get: insert into message_table ( subject, message_text, date_sent,
staff_id ) values ( ?, ?, ?, ? )
Hibernate: insert into message_table ( subject, message_text, date_sent,
staff_id ) values ( ?, ?, ?, ? )
7656 [main] DEBUG <cirrus.hibernate.ps.PreparedStatementCache> Preparing
statement: insert into message_table ( subject, message_text, date_sent,
staff_id ) values ( ?, ?, ?, ? )
7671 [main] DEBUG <cirrus.hibernate.impl.ClassPersister> Dehydrating entity:
domain.Message#null
7671 [main] DEBUG <cirrus.hibernate.ps.PreparedStatementCache> recaching
7671 [main] DEBUG <cirrus.hibernate.impl.SessionFactoryImpl> prepared
statement get: select @@identity
Hibernate: select @@identity
7671 [main] DEBUG <cirrus.hibernate.ps.PreparedStatementCache> Preparing
statement: select @@identity
7671 [main] DEBUG <cirrus.hibernate.impl.ClassPersister> Natively generated
identity: 67463941285871630
7687 [main] DEBUG <cirrus.hibernate.ps.PreparedStatementCache> recaching
7687 [main] DEBUG <cirrus.hibernate.impl.SessionImpl> saving
domain.MessageAddressee#native
7687 [main] DEBUG <cirrus.hibernate.impl.ClassPersister> Inserting entity:
domain.MessageAddressee (native id)
7687 [main] DEBUG <cirrus.hibernate.impl.ClassPersister> Inserting entity:
domain.MessageAddressee#null
7687 [main] DEBUG <cirrus.hibernate.impl.SessionFactoryImpl> prepared
statement get: insert into message_addressee ( message_id,
addressee_group_id, staff_id ) values ( ?, ?, ? )
Hibernate: insert into message_addressee ( message_id, addressee_group_id,
staff_id ) values ( ?, ?, ? )
7687 [main] DEBUG <cirrus.hibernate.ps.PreparedStatementCache> Preparing
statement: insert into message_addressee ( message_id, addressee_group_id,
staff_id ) values ( ?, ?, ? )
7687 [main] DEBUG <cirrus.hibernate.impl.ClassPersister> Dehydrating entity:
domain.MessageAddressee#null
7703 [main] WARN <cirrus.hibernate.helpers.JDBCExceptionReporter> SQL Error:
233, SQLState: 23502
7703 [main] ERROR <cirrus.hibernate.helpers.JDBCExceptionReporter> ASA Error
-195: Column 'message_id' in table 'message_addressee' cannot be NULL
7703 [main] DEBUG <cirrus.hibernate.ps.PreparedStatementCache> recaching
7703 [main] DEBUG <cirrus.hibernate.impl.SessionImpl> closing session
7703 [main] DEBUG <cirrus.hibernate.impl.SessionImpl> disconnecting session
7703 [main] DEBUG
<cirrus.hibernate.connection.DriverManagerConnectionProvider> returning
connection to pool


-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
Hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to