[JBoss-user] [EJB 3.0] - Re: Composite pk/fk

2006-02-09 Thread epbernard
show a code snipset

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3922735#3922735

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3922735


---
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnkkid=103432bid=230486dat=121642
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [EJB 3.0] - Re: composite PK/FK

2006-01-26 Thread DWebster
So, for further enlightenment could you provide a code snippet of a stateless 
session bean that contains a method for returning a list of regions from a 
specific country code?  A partial compound key lookup.  I have never gotten one 
of those to work.

Thanks

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3919936#3919936

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3919936


---
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnkkid=103432bid=230486dat=121642
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [EJB 3.0] - Re: composite PK/FK

2006-01-02 Thread danjourno
i forgot to add referencedColumName to the JoinColumn Annotation when defining 
the foreign composite key relationship.

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3915149#3915149

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3915149


---
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637alloc_id=16865op=click
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [EJB 3.0] - Re: composite PK/FK

2006-01-01 Thread danjourno
yep.. I finally sorted this one out.

I'll post the code for my files for a reference as this is a slightly different 
example to the one in the wiki.

I've included the location class which shows how the composite foreign key is 
referenced.

@Entity
  | @Table(name=country)
  | public class Country  implements Serializable {
  | 
  | java.lang.String countryCode1;
  | 
  | java.lang.String countryCode2;
  | 
  | java.lang.String shortName;
  | 
  | java.lang.String longName;
  | 
  | java.lang.String countryCode3;
  | 
  | java.util.ListCountryRegion countryRegions;
  | 
  | @Id
  | @Column(name=country_code_1)
  | public java.lang.String getCountryCode1() {
  | return countryCode1;
  | }
  | 
  | public void setCountryCode1(java.lang.String countryCode1) {
  | this.countryCode1 = countryCode1;
  | }
  | 
  | @Column(name=country_code_2)
  | public java.lang.String getCountryCode2() {
  | return countryCode2;
  | }
  | 
  | 
  | public void setCountryCode2(java.lang.String countryCode2) {
  | this.countryCode2 = countryCode2;
  | }
  | 
  | @Column(name=country_code_3)
  | public java.lang.String getCountryCode3() {
  | return countryCode3;
  | }
  | 
  | public void setCountryCode3(java.lang.String countryCode3) {
  | this.countryCode3 = countryCode3;
  | }
  | 
  | @Column(name=long_name)
  | public java.lang.String getLongName() {
  | return longName;
  | }
  | 
  | public void setLongName(java.lang.String longName) {
  | this.longName = longName;
  | }
  | 
  | @Column(name=short_name)
  | public java.lang.String getShortName() {
  | return shortName;
  | }
  | 
  | public void setShortName(java.lang.String shortName) {
  | this.shortName = shortName;
  | }
  | 
  | 
  | 
  | @OneToMany(mappedBy=country)
  | public java.util.ListCountryRegion getCountryRegions() {
  | return countryRegions;
  | }
  | 
  | public void setCountryRegions(java.util.ListCountryRegion 
countryRegions) {
  | this.countryRegions = countryRegions;
  | }
  | 
  | 
  | 
  | }
  | 

@Entity
  | @Table(name = country_region)
  | public class CountryRegion implements Serializable {
  | 
  | java.lang.String name;
  | 
  | java.lang.String description;
  | 
  | CountryRegionPK pk;
  | 
  | Country country;
  | 
  | java.util.ListLocation locations;
  | 
  | java.util.ListCompany companies;
  | 
  | public CountryRegion() {
  | }
  | 
  | // mapping of table columns to PK fields
  | // note that the length had to be set so that PK size didn't exceed 
MySQLs 1024 byte max
  | @EmbeddedId
  | @AttributeOverrides({
  |  @AttributeOverride(name = regionCode, column = @Column(name = 
region_code, length=3)),
  |  @AttributeOverride(name = countryCode1, column = 
@Column(name=country_code_1, length=2))
  |})
  | public CountryRegionPK getPk() {
  | return pk;
  | }
  | 
  | public void setPk(CountryRegionPK pk) {
  | this.pk = pk;
  | }
  | 
  | @Column(name = description)
  | public java.lang.String getDescription() {
  | return description;
  | }
  | 
  | public void setDescription(java.lang.String description) {
  | this.description = description;
  | }
  | 
  | @Column(name = name)
  | public java.lang.String getName() {
  | return name;
  | }
  | 
  | public void setName(java.lang.String name) {
  | this.name = name;
  | }
  | 
  | // must use insertable=false and updateable=false when referencing 
country_code_1 for the second time.
  | @ManyToOne(fetch=FetchType.EAGER)
  | @JoinColumn(name=country_code_1, insertable=false, updatable=false)
  | public Country getCountry() {
  | return country;
  | }
  | 
  | public void setCountry(Country country) {
  | this.country = country;
  | }
  | 
  | @OneToMany(fetch=FetchType.LAZY,mappedBy=countryRegion)
  | public java.util.ListCompany getCompanies() {
  | return companies;
  | }
  | 
  | public void setCompanies(java.util.ListCompany companies) {
  | this.companies = companies;
  | }
  | 
  | @OneToMany(fetch=FetchType.LAZY,mappedBy=countryRegion)
  | public java.util.ListLocation getLocations() {
  | return locations;
  | }
  | 
  | public void setLocations(java.util.ListLocation locations) {
  | this.locations = locations;
  | }
  | 
  | }


  | @Embeddable
  | public class CountryRegionPK implements java.io.Serializable{
  | 
  | 
  | 
  | private String countryCode1;
  |private String regionCode;
  | 
  |

[JBoss-user] [EJB 3.0] - Re: composite PK/FK

2005-12-30 Thread epbernard
did you remove this one
@OneToMany(fetch=FetchType.LAZY,mappedBy=country)
  | public java.util.ListCountryRegion getCountryRegion() {
  | return countryRegion;
  | }

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3915034#3915034

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3915034


---
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637alloc_id=16865op=click
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [EJB 3.0] - Re: composite PK/FK

2005-12-29 Thread [EMAIL PROTECTED]
only Basic, Column, Lob, Temporal, and Enumerated can be used to map a 
@Embedded class.  Thus, you can't use Country as a primary key.  That's one 
problem I see.  Another is that the @OneToMany on Country to CountryRegion is 
not bidirectional, so the mappedby would not work.  You'd have to do:


  | @Entity public class Country {
  | ...
  |   @OneToMany
  |   @JoinColumn(name=country_code_1)
  |   ListCountryRegion getCountryRegions() {...}
  | 

There's probably other stuff wrong, but get those to work first

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3914764#3914764

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3914764


---
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637alloc_id=16865op=click
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [EJB 3.0] - Re: composite PK/FK

2005-12-29 Thread danjourno
Thanks Bill,

I'll give that a go an let you know of the results.

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3914854#3914854

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3914854


---
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637alloc_id=16865op=click
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [EJB 3.0] - Re: composite PK/FK

2005-12-29 Thread danjourno
I've just set things up the way you have suggested.

My PK class now has a String value referring to the country_code_1 rather than 
the actual country object.
@Embeddable
  | public class CountryRegionPK implements java.io.Serializable{
  | ...
  | 
  |public String getCountryCode1() {...}
  | 
  |public void setCountryCode1(String countryCode1) { }

@Entity
  | @Table(name = country_region)
  | public class CountryRegion implements Serializable {
  | 
  | @EmbeddedId
  | @AttributeOverrides({
  |  @AttributeOverride(name = regionCode, column = @Column(name = 
region_code)),
  |  @AttributeOverride(name = countryCode1, column = 
@Column(name=country_code_1))
  |})
  | 

However I am still getting the error below. I'm guessing that it is due to my 
Location table relationship. see bottom.

org.hibernate.AnnotationException: A Foreign key refering CountryRegion has the 
wrong number of column. should be 2


  | @Entity
  | @Table(name=location)
  | public class Location implements Serializable{
  | ...
  | @ManyToOne
  | @JoinColumns ( [EMAIL PROTECTED](nullable=false, name=region_code), 
@JoinColumn(nullable=false, name=country_code_1)})
  | public CountryRegion getCountryRegion() {
  | return countryRegion;
  | }
  | 


View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3914881#3914881

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3914881


---
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637alloc_id=16865op=click
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user