Hibernate version:2.1.7
Name and version of the database you are using:hsqldb 1.7.1
hi
first of all, thanks for giving us this powerful tool, and sorry for my poor english
i need to 'translate' my database identifiers from 'native' to 'uuid.hex', in order to tranfer data between applications in a network environment.
the domain model is very complex, and consists in a object graph with a Project 'parent' class, and i can't simply do it with manual queries because of foreign key constraints
now i have:
- some 'old' databases, with 'native' identifiers;
- a 'new' database, with the new schema and old data (native id - int - are inserted as strings)
My idea was to session.load() the graph from a session, then save() it in a new session, configured with some specific mapping like this:
Code:
<class name="Project" table="PROJECT">
<id
column="ID"
name="Id"
type="string"
length="32"
unsaved-value="any"
>
<generator class="uuid.hex" />
</id>
.
.
.
this, obviously, won't work :)
my log:
Code:
.
.
saving [it.oduestudio.srg.vo.Recapito#402881b201870df70101870e25b60009] - SessionImpl:834
saveOrUpdate() persistent instance - SessionImpl:1381
saveOrUpdate() unsaved instance - SessionImpl:1396
generated identifier: 402881b201870df70101870e25b6000a - SessionImpl:787
saving [it.oduestudio.srg.vo.Recapito#402881b201870df70101870e25b6000a] - SessionImpl:834
saveOrUpdate() persistent instance - SessionImpl:1381
saveOrUpdate() unsaved instance - SessionImpl:1396
generated identifier: 402881b201870df70101870e25c6000b - SessionImpl:787
saving [it.oduestudio.srg.vo.PersonaIncaricata#402881b201870df70101870e25c6000b] - SessionImpl:834
saveOrUpdate() unsaved instance - SessionImpl:1396
generated identifier: 402881b201870df70101870e25c6000c - SessionImpl:787
saving [it.oduestudio.srg.vo.Persona#402881b201870df70101870e25c6000c] - SessionImpl:834
saveOrUpdate() persistent instance - SessionImpl:1381
saveOrUpdate() unsaved instance - SessionImpl:1396
generated identifier: 402881b201870df70101870e25c6000d - SessionImpl:787
saving [it.oduestudio.srg.vo.Ubicazione#402881b201870df70101870e25c6000d] - SessionImpl:834
saveOrUpdate() unsaved instance - SessionImpl:1396
generated identifier: 402881b201870df70101870e25c6000e - SessionImpl:787
saving [it.oduestudio.srg.vo.ElencoRecapiti#402881b201870df70101870e25c6000e] - SessionImpl:834
transaction completion - SessionImpl:594
closing session - SessionImpl:576
disconnecting session - SessionImpl:3371
transaction completion - SessionImpl:594
closing session - SessionImpl:576
net.sf.hibernate.PropertyValueException: not-null property references a null or transient value: it.oduestudio.srg.vo.Persona.Azienda - Conversione1_1_19to1_2_0:83
net.sf.hibernate.PropertyValueException: not-null property references a null or transient value: it.oduestudio.srg.vo.Persona.Azienda
at net.sf.hibernate.impl.SessionImpl.checkNullability(SessionImpl.java:1286)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:937)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:866)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:788)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:747)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1397)
at net.sf.hibernate.engine.Cascades$4.cascade(Cascades.java:114)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:436)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:503)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:899)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:866)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:788)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:747)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1397)
at net.sf.hibernate.engine.Cascades$4.cascade(Cascades.java:114)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:436)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:503)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:899)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:866)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:788)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:747)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1397)
at net.sf.hibernate.engine.Cascades$4.cascade(Cascades.java:114)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:436)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:503)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:899)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:866)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:788)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:747)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1397)
at net.sf.hibernate.engine.Cascades$4.cascade(Cascades.java:114)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:436)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:503)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:899)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:866)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:788)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:747)
at it.oduestudio.srg.util.Conversione1_1_19to1_2_0.convertAndTransfer(Conversione1_1_19to1_2_0.java:220)
at it.oduestudio.srg.util.Conversione1_1_19to1_2_0.main(Conversione1_1_19to1_2_0.java:79)
.
.
this seems to be ok (ids are well generated), but when hibernate tries to access to an object previously changed and referenced by another, it throws an exception
can this caused by equals() or hashCode() implementation of my beans?