java - hibernate: insert instance with external "id class" -
i'm using hibernate + hsql on jboss server, need saveorupdate() object has id represented class:
public class rideid implements java.io.serializable { private int beginpop; private int endpop; private string requestuser; public rideid() { } public rideid(int beginpop, int endpop, string requestuser) { this.beginpop = beginpop; this.endpop = endpop; this.requestuser = requestuser; } ...
so, "rideid" id of entity "ride"
public class ride implements java.io.serializable { private rideid id; private user userbyrequestuser; private user userbyacceptuser; private pop pop; private boolean ridestatus; public ride() { } public ride(rideid id, user userbyrequestuser, pop pop) { this.id = id; this.userbyrequestuser = userbyrequestuser; this.pop = pop; } public ride(rideid id, user userbyrequestuser, user userbyacceptuser, pop pop, boolean ridestatus) { this.id = id; this.userbyrequestuser = userbyrequestuser; this.userbyacceptuser = userbyacceptuser; this.pop = pop; this.ridestatus = ridestatus; } ...
how can saveorupdate() new object of type ride?
thanks , sorry english!
it's simple. need create first new rideid
, assign new ride
, call saveorupdate
ride
.
rideid id = new rideid(1, 2, "someuser"); ride ride = new ride(id, ...); session.saveorupdate(ride);
Comments
Post a Comment