java - Hibernate loading associated entities not by primary key -


i have 2 tables (really simplified sake of question):

book {   id integer,   name string,   author_id integer }  author {   id integer,   fullname string } 

now need save book, don't have author_id, have author's fullname.

i can author name, book.set(thatauthor), have more fields in many classes, have fill objects , it's more code this, since i'm using map-struct map , call persist , done it, can't, have set fields manually.

question: there possiblity tell hibernate it? have entity class filled data (author's fullname set) , it's unique if hibernate tried find 1 result, no problems there.

i have in mind such functionality: hibernate looks @ class. sees fields set , other not. takes fields set , puts them in where clause (in case it's authors fullname) , tries find single result, throws exception otherwise.

not sure if can understand me, tried best. don't hate me question, find did, loading objects manually. if can possibly avoid lots of code asking question - why not try?


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -