cancel
Showing results for 
Search instead for 
Did you mean: 

EJB/JPA Session/Entity Bean: Back Reference Id not set

Former Member
0 Kudos

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 ???

Accepted Solutions (1)

Accepted Solutions (1)

former_member185086
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Dear Satish,

thks for reply, the doc u referred to me containing simple example. I want an Entity that hold the Collection of another Entities.

Answers (2)

Answers (2)

Former Member
0 Kudos

thks all

Former Member
0 Kudos

>

> Second thing is that how to generate automatically primary keys when entity saved in database ???

Hello kapitsu,

what database are you using?

Former Member
0 Kudos

Database: SqlServer2008.

JPA, Session/Entity Beans

Former Member
0 Kudos

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.