Here is relationship in the mapping file (MainTransaction.hbm.xml).. Mapping is okay. The problem is that I get the exception(No row with the given identifier exists:)
When I execute the "mainTransaction.getSubTran" getter method with no related record in subTransaction table. I do not want the exeception. I just want to check whether null or not and want to continue the program execution..
Here is the error messages.. I know that there is no related record in SubTransaction table.. But I want to return null. I do not want to throw the exception.
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [SubTransaction#SubTransactionPK@aa233f]
Note : There is no physical relationship between two tables.
posted 10 years ago
When you define the <many-to-one> and point the <column> attributes to another table, you are defining a FK relationship. If that foreign key doesn't exist, then you can't have the values populated in the MainTransaction object. If they have no physical relationship, then don't map a Hibernate relationship between the two. You'll just have to load the data you need and manage the object relationship yourself.