on 10-06-2009 8:26 AM
Hello All,
I m using JPA as a persist tool. I have an entity Account and in Account there is a collection of entity AccountDetail. In Account entity relation for AccountDetail is One-To-Many and in AccountDetail the relation for Account is Many-To-One. When i save the Account, object of Account and AccountDetail are saved correctly. But the problem is that in AccountDetail the Id of Account is not saved in Database table. I have AccountId in AccountDetail table. plz help me??
Second thing is that how to generate automatically primary keys when entity saved in database ???
Hi
Its a more technical and from other forum better to take help from [this|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/502f70a8-33a4-2b10-3dbe-bdcb5e25c6da&overridelayout=true]
Best Regards
Satish Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thks all
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>
> Second thing is that how to generate automatically primary keys when entity saved in database ???
Hello kapitsu,
what database are you using?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
define the column you want to auto increment as an Integer with Identity attribute set to True (using the sql server management tool for example) and then put
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
in front of the ID declaration in the mapping file, it should generate the IDs automatically.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.