• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Create constraint

 
assaf aharoni
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to 2 objects: Purchase Orders and Items
i would like to create constraint between those class to Items.class with companyId and itemsCode but those columes are seperated into two classes.
what can be a solution for that ?

 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You you want to create a constraint on the database, or a OneToOne mapping in JPA?

A OneToOne mapping should work, but your Item must define an Id, (both companyId and itemCode should be its Id).

Then you can define a normal OneToOne in PerchaseOrderLine to Item,

i.e.


 
assaf aharoni
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works, thank you.
 
assaf aharoni
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now the problem is different. i can see that hibernate run the right query but doesn't initialize my objects and one objects above.
its stays null, even so he creates the array.
 
assaf aharoni
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since i added this variable (Item) the object holding it became empty. and nothing is retrieved.


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic