0

I have a problem in creating proper hibernate mappings for my web application.

I have a table User (primary key is id). The user table has data that doesn't change too often for a user. I have another table user_editable_data that has data editable by the user. The table structure is as below

User id|username|password

user_editable_data id|info1|info2

The id in user_editable_data is same as User.id

I have two entities (User and UserEditableData) corresponding to the tables. My requirement is that i need to create an entry in user_editable_data table whenever an user is created.

I am able to do this successfully by using hibernate mappings by following the tutorial here. But with that i should have an object of User in UserEditableData class which i dont want to use.

I tried using mapping. But with that only the object of User is getting created when i persist User object.

Can someone suggest me a way to map User and UserEditableData such that when we persist/create User, UserEditableMapping should also get created with the same id as in User.

Any help is appreciated.

Anirudhan J
  • 2,072
  • 6
  • 27
  • 45

1 Answers1

0

Get rid of UserEditableData and map both tables to the same class as explained here or here. You can find the official documentation of the <join> tag in the Hibernate Manual, section 5.1.20

Community
  • 1
  • 1
Soronthar
  • 1,601
  • 10
  • 10