I do want seperate tables. I don't want mega bloated tables with loads of columns. My profile class has about 15 properties.
Surely, what I want to do is doable. I feel like this is Hibernate 101, but somehow it seems incredibly hard to get it done. Anyway, the update in stead of insert seems to occur because the generated id on subscriber does not get assigned to the profile class.
My debug out put is as follows (edited for clarity purpose):
Code:
processing cascades for: Subscriber
done processing cascades for: Subscriber
id unsaved-value strategy NULL
id unsaved-value strategy NULL
Inserting entity: Subscriber (native id)
about to open: 0 open PreparedStatements, 0 open ResultSets
insert into Users (dateAdded, online, hits,Subclass) values (?, ?, ?,'S')
Hibernate: insert into Users (dateAdded, online, hits,Subclass) values (?, ?, ?, 'S')
preparing statement
Dehydrating entity: [Subscriber#<null>]
binding '2005-01-16 16:08:09' to parameter: 1
binding 'false' to parameter: 2
binding '0' to parameter: 3
Natively generated identity: 2
done closing: 0 open PreparedStatements, 0 open ResultSets
closing statement
processing cascades for: Subscriber
cascading to saveOrUpdate()
id unsaved-value strategy NULL
saveOrUpdate() previously saved instance with id: 0
updating [nl.msw.dates4free.business.entities.profile.Profile#0]
done processing cascades for: Subscriber
commit
flushing session
processing cascades for: Subscriber
cascading to saveOrUpdate()
saveOrUpdate() persistent instance
done processing cascades for: Subscriber
Flushing entities and processing referenced collections
Updating entity: [Profile#0]
Processing unreferenced collections
Scheduling collection removes/(re)creates/updates
Flushed: 0 insertions, 1 updates, 0 deletions to 2 objects
Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
listing entities:
Profile{eyeColor=null, religion=null, subscriberID=0, length=0}
Subscriber{dateAdded=2005-01-16 16:08:09, photos=null, userID=2, hits=0, profile=Profile#0}
executing flush
Updating entity: [Profile#0]
about to open: 0 open PreparedStatements, 0 open ResultSets
update Profiles set hit=?, kids=?, kidshome=?, length=?,subscriberID=? where SubscriberID=?
Hibernate: update Profiles set hit=?, kids=?, kidshome=?, length=?, subscriberID=? where SubscriberID=?
preparing statement
Dehydrating entity: [Profile#0]
binding '0' to parameter: 1
binding 'false' to parameter: 2
binding 'false' to parameter: 3
binding '0' to parameter: 4
binding '0' to parameter: 7
Adding to batch
Executing batch size: 1
done closing: 0 open PreparedStatements, 0 open ResultSets
Kind regards,
Marc[/code]