-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: constraint from different objects
PostPosted: Mon Aug 09, 2010 6:35 am 
Newbie

Joined: Sun Aug 09, 2009 12:14 pm
Posts: 16
I have to 2 objects: Purchase Orders and Items
i would like to create constraint between ELCWEB.ELC_PO_LINES to Items.class with companyId and itemsCode but those columns are separated into two classes.
what can be a solution for that ?

Code:
   1. @Entity 
   2. @Table(name = "ELCWEB.ELC_PO_LINES") 
   3. public class PerchaseOrderLines { 
   4.       
   5.     @EmbeddedId 
   6.     public PerchaseOrderLinesPK perchaseOrderLinesPK; 
   7.       
   8. @Column(name="POL_ITEM_CODE") 
   9.     private String itemCode; 
  10.   
  11. } 
  12.   
  13. @Embeddable 
  14. public class PerchaseOrderLinesPK implements Serializable { 
  15.       
  16.     private static final long serialVersionUID = -2968018113431114592L; 
  17.   
  18.     @Column(name = "POH_PO_NUM") 
  19.           private String poNum; 
  20.   
  21.         @Column(name="COMPANY_ID") 
  22.     private Integer companyId; 
  23. } 
  24. @Entity 
  25. public class Items { 
  26.        @Column(name = "COMPANY_ID") 
  27.           private String companyId; 
  28.   
  29.     @Column(name = "ITEM_CODE") 
  30.           private String itemCode; 
  31. } 


Top
 Profile  
 
 Post subject: Re: constraint from different objects
PostPosted: Mon Aug 09, 2010 7:22 am 
Regular
Regular

Joined: Fri Aug 06, 2010 1:49 am
Posts: 102
Location: shynate26@gmail.com
Hi,

You want to create constraint in database schema ? If not then there is no problem . Because many-to-one mapping can be crated even if there is no constraints in database table.

Get back , what is your real requirement.

_________________

Cheers!
Shynate
mailto:shynate26@gmail.com
www.CSSCORP.com


Top
 Profile  
 
 Post subject: Re: constraint from different objects
PostPosted: Mon Aug 09, 2010 8:39 am 
Newbie

Joined: Sun Aug 09, 2009 12:14 pm
Posts: 16
In DB schema there is no problem, the constraint exist and working fine.
My problem is how to make the ORM with hibernate.
The constraint is combined with one to many.
itemCode and companyId from PerchaseOrderLines and PerchaseOrderLinesPK should together should be bound to the Item.class
if i had one class for PerchaseOrderLines without the @embeddedId to PK class i could just do without any problem.
My question is how can i create this constraint when my fields exists in two different classes representing one table.

I hope its a good explanation of my situation.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.