This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Create constraint  RSS feed

 
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.


 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!