Ok, and which line is this: com.test.service.TestServiceBean.testOnDBError(Tes tServiceBean.java:4
2)
Ok, and which line is this: com.test.service.TestServiceBean.testOnDBError(Tes tServiceBean.java:4
2)
Code:public void testOnDBError(){ this.impl.testOnDBError(); }
and the impl is:
Code:public void testOnDBError() { System.out.println("getPOJO"); POJO p = this.dao.getPOJO(); System.out.println("setDateDerniereModification"); p.setDateDerniereModification(new Date()); // on fait planter au commit System.out.println("setValeurNonNullable"); p.setValeurNonNullable(null); }
Last edited by david.chau; Jan 31st, 2007 at 04:17 AM. Reason: add impl
If
this.impl.testOnDBError();
is line 42 then impl is for some reason null, has nothing to do with database.
OK SORRY my fault (I am not awake yet...)
Here is the log.
I apologize for the mistake
The exception here, is one of lazy initialization as the session has closed. This was a change from Hibernate 2 to 3 as the default behaviour. This has nothing to do with Spring.
http://www.hibernate.org/250.htmlSince it is best practice to map almost all classes and collections using lazy="true", that is now the default. Existing applications will need to explicitly specify lazy="false" on all non-lazy class and collection mappings.
Solutions to this in unit tests are discussed here.
http://forum.springframework.org/showthread.php?t=9630
http://forum.hibernate.org/viewtopic.php?t=929167
http://www.springframework.org/docs/...tml#testing-tx
Last edited by karldmoore; Jan 31st, 2007 at 04:54 AM.
I put lazy="false".
It seems that the RuntimeException is not thrown...![]()
Well, yes, now you made it work like it did with H2 and it works again.
Edit: Ignore, I didnt understand what you mean at first.
Are you saying it now works?? If if so.................
Hibernate 3 defaults to lazy initialization, this issue has been re-hashed lots of times on the web. I would google and see what you can find. The link I added discusses the changes from Hibernate 2 to 3. I wouldn't personally just change them to all be eager (non-lazy) and be happy with that. I'd have more of a think if it made sense to like that in the first place. If you aren't that bothered just change them and your system will function as before.
You are telling me inserting null in a not nullable column does not throw anymore a HibernateException (that inherits from RuntimeException) and that is a normal behaviour?
My test in S1.1.2 + H2 threw a HibernateException, so the session was rollbacked AND the connection was closed.
now, there is no HibernateException (that could be a problem, I do not know yet) and the connection is closed.
You are not updating anything, that's the problem. The session is opened and closed in the first line, and the changes you do with setters are done only in memory.
Anyway, what is the point of changing spring/hibernate version for you? Hibernate 3 changed a lot of things and not everything works as it used to. On the other hand you seem very inpatient at making it work again.