Force « Insert « JPA Q&A





1. Hibernate - Force foreign key lookup on insert    coderanch.com

Hello These are the mappings of my SQL DB: USERACCOUNT ------------- Userid (PK) --autoincrement USERACCOUNTInvoice ------------- Userid (PK) -Foreign Key to the above Invoics(PK) --autoincrement In my app I create a new UserAccountInvocie object which I persist by doing a session,save(useraccount) I get an error saying Cannot intert null into UserAccountInvoiceTable for field UserID NOTE: there are a number of USERACCOUNTInvoice ...

2. Force insert on persistent object    forum.hibernate.org

Once you saved your object it is in the persistant state (as mentioned by urs_b read the reference here). You cannot change the primary key of an object in this state as long it is connected to a session. So your choice is a) close session -> change primary key -> save which I do not recommend b) make a copy ...

3. Can you force an update, instead of delete/insert    forum.hibernate.org

I've been doing Hibernate for all of maybe 2 months and I must say, it's been great once I've learned how to use it. I'm actually using Spring 2.0 also and it really eliminates alot of coding, especially code concerning transactions and sessions. I have a User (see mapping below) that has a unique constraint in the database on username& mainclientid. ...