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.  [ 1 post ] 
Author Message
 Post subject: help acces set elements
PostPosted: Fri Nov 20, 2009 9:44 am 
Newbie

Joined: Fri Nov 20, 2009 9:26 am
Posts: 4
I'm a beginner and I cannot imagine what's wrong wit my code.

I have two tables with many to many relationship between them:

first table Owner:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="entity.Owner" table="OWNER">
<meta attribute="class-description">This class contains owner details.</meta>
<id column="OWNER_ID" name="id" type="long">
<generator class="native"/>
</id>
<property column="NUME" length="100" name="nume" not-null="false" type="string"/>
<property column="INITIALA" length="100" name="initiala" not-null="false" type="string"/>
<property column="PRENUME" length="100" name="prenume" not-null="false" type="string"/>
<property column="NUMECONT" length="100" name="numecont" not-null="false" type="string"/>
<set cascade="all" name="ownerTelefon" table="OWNER_TELEFON" >
<key column="OWNER_ID_R"/>
<many-to-many column="TELEFON_ID_R" class="entity.Telefon"/>
</set>

</hibernate-mapping>



second table Telefon:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="entity.Telefon" table="TELEFON">
<meta attribute="class-description">This class contains owner's phone number
details.</meta>
<id column="TELEFON_ID" name="id" type="long">
<generator class="native"/>
</id>
<property column="TELTEXTBOX" length="20" name="teltextbox" type="string"/>
<property column="TIPTEXTBOX" length="20" name="tiptextbox" type="string"/>
<property column="CORESP_VDF" length="20" name="coresp_vdf" type="string"/>
<property column="SCURT_VDF" length="20" name="scurt_vdf" type="string"/>
<property column="GRUP" name="grup" type="integer"/>
<property column="IS_CFR" name="is_cfr" type="boolean"/>
<set name="owners" table="OWNER_TELEFON">
<key column="TELEFON_ID_R"/>
<many-to-many column="OWNER_ID_R" class="entity.Owner"/>
</set>




the class for Owner is :

public class Owner implements Serializable {

public Owner(){
}

public Owner(String nume){
this.nume=nume;
}

public Owner(String nume, Collection<Telefon> ownerTelefon){
this.nume=nume;
this.ownerTelefon=ownerTelefon;
}

private Long id;
private String nume;
private String prenume;
private String initiala;
private String numecont;
private Collection<Telefon> ownerTelefon;


public Long getId() {
return id;
}


public void setId(Long id) {
this.id = id;
}


public String getNume() {
return nume;

}

public void setNume(String nume) {
this.nume = nume;
}

public String getPrenume() {

return prenume;
}

public void setPrenume(String prenume) {
this.prenume = prenume;
}


public String getInitiala() {

return initiala;


}

public void setInitiala(String initiala) {
this.initiala = initiala;
}

public String getNumecont() {
if (isValidNumecont()) {
return numecont;
}
return "Nu a fost introdus nume cont";
}


public void setNumecont(String numecont) {
this.numecont = numecont;
}

public Collection<Telefon> getOwnerTelefon(){
return ownerTelefon;
}

/**
* @param telefon the telefon to set
*/
public void setOwnerTelefon(Collection<Telefon> ownerTelefon) {
this.ownerTelefon = ownerTelefon;
}







the class for Telefon is :


public class Telefon implements Serializable {

public Telefon() {

}

public Telefon(String tiptextbox, String teltextbox) {
this.tiptextbox=tiptextbox;
this.teltextbox=teltextbox;
}



private Long id;
private String teltextbox;
private String tiptextbox;
private String coresp_vdf;
private String scurt_vdf;
private Boolean is_cfr;
private Collection<Owner> owners;




public Long getId() {
return id;
}


public void setId(Long id) {
this.id = id;
}


public String getTeltextbox() {
return teltextbox;
}


public void setTeltextbox(String teltextbox) {
this.teltextbox = teltextbox;
}


public String getTiptextbox() {
return tiptextbox;
}


public void setTiptextbox(String tiptextbox) {
this.tiptextbox = tiptextbox;
}


public String getCoresp_vdf() {
return coresp_vdf;
}

public void setCoresp_vdf(String coresp_vdf) {
this.coresp_vdf = coresp_vdf;
}


public String getScurt_vdf() {
return scurt_vdf;
}

public void setScurt_vdf(String scurt_vdf) {
this.scurt_vdf = scurt_vdf;
}

public Boolean getIs_cfr() {
return is_cfr;
}

public void setIs_cfr(Boolean is_cfr) {
this.is_cfr = is_cfr;
}




public Collection<Owner> getOwners() {
return owners;
}

public void setOwners(Collection<Owner> owners) {
this.owners = owners;
}


}



How could I get the ownerTelefon set for a specified Owner.id ???


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

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.