-->
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.  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: One To Many Relationship Using Not Using Foreign key?
PostPosted: Thu Aug 19, 2004 5:40 am 
Beginner
Beginner

Joined: Thu Aug 19, 2004 5:20 am
Posts: 25
Hibernate version: 2.1.3

Mapping documents:

<!--DTRNS MAPPING-->
<hibernate-mapping>
<class name="DTrns" table="d_trns" dynamic-update="true" >
<id name="trnID" column="trn_id" type ="java.lang.Long" unsaved-value="null">
<generator class="native" />
</id>

<bag name="dDetails" inverse="true" lazy="true" cascade="all">
<key column="trn_id"/>
<one-to-many class="DDetails"/>
</bag>
</class>
</hibernate-mapping>


<!--DEPFILESIN MAPPING-->
<hibernate-mapping>
<class name="DEpFilesIn" table="d_epfilesin">
<id name="id" column="id" type ="java.lang.Long" unsaved-value="null">
<generator class="native" />
</id>
<property name="subject" column="subject" not-null="false"/>
<set name="dDetails" inverse="true" lazy="true">
<key column="filesin_id"/>
<one-to-many class="DDetails"/>
</set>
</class>
</hibernate-mapping>

<!--DDETAILS MAPPING -->
<hibernate-mapping>
<class name="DDetails" table="d_details">
<id name="id" column="id" type ="java.lang.Long" unsaved-value="null">
<generator class="native" />
</id>

<property name="filesInID" column="filesin_id" not-null="false"/>
<many-to-one name="dEpFilesIn" class="DEpFilesIn" column="id" not-null="false"/>

</class>
</hibernate-mapping>




Code between sessionFactory.openSession() and session.close():
DTrns dtransObj = (DTrns)normalSession.load(DTrns.class,new Long(2290156));
System.out.println("DTRNS TRN ID " + dtransObj.getTrnID());
//LOADS DDetails
List list = dtransObj.getdDetails();
if(list.size()>0)
{
Iterator it = list.iterator();
while(it.hasNext())
{
DDetails dDetailsObj = (DDetails)it.next();
System.out.println("DDETAILS FILES_IN_ID " + dDetailsObj.getFilesInID());
//LOADS D_EPFilesIn
Set dEpFilesInList = dDetailsObj.getdEpFilesIn();
if(dEpFilesInList!=null && (dEpFilesInList.size()>0))
{
Iterator et = dEpFilesInList.iterator();
while(et.hasNext())
{
DEpFilesIn dEpFilesInObj = (DEpFilesIn)et.next();
System.out.println("DEPFILESIN FILES ID " + dEpFilesInObj.getFilesId() + " ID " + dEpFilesInObj.getId());
}
}
}
}
System.out.println("");

Full stack trace of any exception that occurs:
1516 [main] ERROR collection.PersistentCollection - Failed to lazily initialize a collection
net.sf.hibernate.ObjectNotFoundException: No row with the given identifier exists: 3770246, of class: DEpFilesIn
at net.sf.hibernate.impl.SessionImpl.throwObjectNotFound(SessionImpl.java:1663)
at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1702)
at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:62)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1933)
at net.sf.hibernate.loader.Loader.doFind(Loader.java:184)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:492)
at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:90)
at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2734)
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:140)
at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:60)
at net.sf.hibernate.collection.Bag.size(Bag.java:194)
at XMLTest.getQuery(XMLTest.java:85)
at XMLTest.main(XMLTest.java:229)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
net.sf.hibernate.ObjectNotFoundException: No row with the given identifier exists: 3770246, of class: DEpFilesIn
at net.sf.hibernate.impl.SessionImpl.throwObjectNotFound(SessionImpl.java:1663)
at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1702)
at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:62)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1933)
at net.sf.hibernate.loader.Loader.doFind(Loader.java:184)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:492)
at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:90)
at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2734)
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:140)
at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:60)
at net.sf.hibernate.collection.Bag.size(Bag.java:194)
at XMLTest.getQuery(XMLTest.java:85)
at XMLTest.main(XMLTest.java:229)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
rethrown as net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection: No row with the given identifier exists: 3770246, of class: DEpFilesIn
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:152)
at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:60)
at net.sf.hibernate.collection.Bag.size(Bag.java:194)
at XMLTest.getQuery(XMLTest.java:85)
at XMLTest.main(XMLTest.java:229)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Caused by: net.sf.hibernate.ObjectNotFoundException: No row with the given identifier exists: 3770246, of class: DEpFilesIn
at net.sf.hibernate.impl.SessionImpl.throwObjectNotFound(SessionImpl.java:1663)
at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1702)
at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:62)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1933)
at net.sf.hibernate.loader.Loader.doFind(Loader.java:184)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:492)
at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:90)
at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2734)
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:140)
... 9 more


Name and version of the database you are using:
MYSQL 3.23.38-nt

Debug level Hibernate log excerpt:

[b] DEpfilesin and DDetails are a one to many relationship
1 Depfilesin could have many DDetails records

3770246 Is the value that is stored in DDetails.id
I want it to use the value that is stored in DDetails.filesin_id when it does the link between the two
How do i make it do this?


Top
 Profile  
 
 Post subject: Re: One To Many Relationship Using Not Using Foreign key?
PostPosted: Thu Aug 19, 2004 5:48 am 
Regular
Regular

Joined: Wed Aug 18, 2004 5:16 am
Posts: 69
Location: Modena, Italy
speedfox_2002 wrote:
<!--DDETAILS MAPPING -->
<hibernate-mapping>
<class name="DDetails" table="d_details">
<id name="id" column="id" type ="java.lang.Long" unsaved-value="null">
<generator class="native" />
</id>

<property name="filesInID" column="filesin_id" not-null="false"/>
<many-to-one name="dEpFilesIn" class="DEpFilesIn" column="id" not-null="false"/>

</class>
</hibernate-mapping>


Try to use column="filesin_id" in many-to-one association (the property filesInID is useless I think) in the mapping of the class DDetails


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 5:50 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
beware if you declare a relationship and your db has corrupted data (can occure if you don't have fk declared), you can get this exception.

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 6:44 am 
Beginner
Beginner

Joined: Thu Aug 19, 2004 5:20 am
Posts: 25
Hi

I cant add foreign keys to the MYSql table, it doesnt have the capability, does MYSql allow foreign keys? i dont think it does.

The filesin_id field is what is used to link DEPFILESIN.id and DDETAILS.filesid_id

I tried changing the id to filesin_id but it gives me the error below

should the code have worked though? can you see any other obvious errors with it? perhaps its a setup issue and there is nothing wrong with the mappings?

Please note as well...that DTRNS and DDETAILS is a one to many relationship as well as DEPFILESIN and DDETAILS...could this have an effect? Ie im using DTRNS to get DDETAILS which im then trying to use to get DEPFILESIN even though DEPFILESIN is a one to many relationship with DDETAILS. I think this is bidirectionality? is that correct?

2719 [main] ERROR collection.PersistentCollection - Failed to lazily initialize a collection
java.lang.ClassCastException
at DDetailsMetaClass2.setPropertyValues(<generated>)
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:155)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1935)
at net.sf.hibernate.loader.Loader.doFind(Loader.java:184)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:492)
at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:90)
at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2734)
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:140)
at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:60)
at net.sf.hibernate.collection.Bag.size(Bag.java:194)
at XMLTest.getQuery(XMLTest.java:85)
at XMLTest.main(XMLTest.java:229)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
rethrown as
net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB setter of DDetails.?
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:160)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1935)
at net.sf.hibernate.loader.Loader.doFind(Loader.java:184)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:492)
at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:90)
at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2734)
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:140)
at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:60)
at net.sf.hibernate.collection.Bag.size(Bag.java:194)
at XMLTest.getQuery(XMLTest.java:85)
at XMLTest.main(XMLTest.java:229)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Caused by: java.lang.ClassCastException
at DDetailsMetaClass2.setPropertyValues(<generated>)
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:155)
... 15 more
java.lang.ClassCastException
at DDetailsMetaClass2.setPropertyValues(<generated>)
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:155)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1935)
at net.sf.hibernate.loader.Loader.doFind(Loader.java:184)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:492)
at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:90)
at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2734)
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:140)
at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:60)
at net.sf.hibernate.collection.Bag.size(Bag.java:194)
at XMLTest.getQuery(XMLTest.java:85)
at XMLTest.main(XMLTest.java:229)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
rethrown as net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB setter of DDetails.?
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:160)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1935)
at net.sf.hibernate.loader.Loader.doFind(Loader.java:184)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:492)
at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:90)
at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2734)
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:140)
at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:60)
at net.sf.hibernate.collection.Bag.size(Bag.java:194)
at XMLTest.getQuery(XMLTest.java:85)
at XMLTest.main(XMLTest.java:229)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Caused by: java.lang.ClassCastException
at DDetailsMetaClass2.setPropertyValues(<generated>)
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:155)
... 15 more
rethrown as net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection: exception setting property value with CGLIB setter of DDetails.?
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:152)
at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:60)
at net.sf.hibernate.collection.Bag.size(Bag.java:194)
at XMLTest.getQuery(XMLTest.java:85)
at XMLTest.main(XMLTest.java:229)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Caused by: net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB setter of DDetails.?
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:160)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1935)
at net.sf.hibernate.loader.Loader.doFind(Loader.java:184)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:492)
at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:90)
at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2734)
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:140)
... 9 more
Caused by: java.lang.ClassCastException
at DDetailsMetaClass2.setPropertyValues(<generated>)
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:155)
... 15 more


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 7:15 am 
Regular
Regular

Joined: Wed Aug 18, 2004 5:16 am
Posts: 69
Location: Modena, Italy
Do you have added to DDetails class the
Code:
public void setDEpFilesIn(DEpFilesIn aDEpFilesIn){...}

and
Code:
public DEpFilesIn getDEpFilesIn(){...}

?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 7:34 am 
Beginner
Beginner

Joined: Thu Aug 19, 2004 5:20 am
Posts: 25
Hi

The methods dont return a specific instance of the DEPfilesIN class, they returna set containing instances(Objects) of the DEPFilesIn class

Do you think it would make a difference if i use Set or Bag? I have tried bag and it doesnt work either

public Set getdEpFilesIn()
{
return dEpFilesIn;
}

public void setdEpFilesIn(Set dEpFilesIn)
{
this.dEpFilesIn = dEpFilesIn;
}


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 7:42 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
No row with the given identifier exists: 3770246, of class: DEpFilesIn

check this id in db : 3770246
it is present in the "parent" table?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject: Re: One To Many Relationship Using Not Using Foreign key?
PostPosted: Thu Aug 19, 2004 7:42 am 
Regular
Regular

Joined: Wed Aug 18, 2004 5:16 am
Posts: 69
Location: Modena, Italy
speedfox_2002 wrote:
DEpfilesin and DDetails are a one to many relationship
1 Depfilesin could have many DDetails records


If this is true you have a collection (Set or other) of DDetails in the Depfilesin class and the istance of Depfilesin in the DDetails (only for bidirectional associations).

If a DDetails can have many Depfilesin then the relation is many-to-many


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 7:50 am 
Beginner
Beginner

Joined: Thu Aug 19, 2004 5:20 am
Posts: 25
No.

1 DEPFILESIN can have many DDETAILS but DDEtails can only have 1 DEPFILES IN

do you think there might be a problem with the fact that DTRNS has Many DDetails But DDetails is used to get DEPFILESIN, BUT...DEPFILESIN has many DDETAILS AS WELL? is this bidirectional association possible?

hierachy is as follows


DTRNS-->--(HAS MANY)->--DDETAILS-->--(HAS ONE)-->-DEPFILESIN ---<---(HAS MANY DDETAILS)

I dont know if that made sense...difficult to draw UML here

I know its a difficult associtation with a one-to-many on either side of DDEtails...but this is the Database as ive been given it, is there a solution?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 7:54 am 
Beginner
Beginner

Joined: Thu Aug 19, 2004 5:20 am
Posts: 25
anthony wrote:
No row with the given identifier exists: 3770246, of class: DEpFilesIn

check this id in db : 3770246
it is present in the "parent" table?


Hi

The above is present in the parent table, however its trying to link to the DDETAILS.ID column which has the value 3770246 and not the DDETAILS.FILESIN_ID column which i need it to link to, the DDETAILS.FILESIN_ID column is not a primary key(DDETAILS.ID is) and i need it the following link:

DDETAILS.FILESIN_ID(not primary key) to DEPFILESIN.ID(primary key)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 7:58 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
http://www.hibernate.org/hib_docs/refer ... -manytoone

property-ref

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 8:04 am 
Regular
Regular

Joined: Wed Aug 18, 2004 5:16 am
Posts: 69
Location: Modena, Italy
If you have corrected the many-to-one column of the mapping of the class DDetails you have only to correct java classes:

DDetails has a dEpFilesIn property of type DEpFilesIn (not a collection)
DEpFilesIn has a collection (Set) dDetails of objects of type DDetails


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 8:10 am 
Beginner
Beginner

Joined: Thu Aug 19, 2004 5:20 am
Posts: 25
Hi Anthony, i think that will work but im not sure how to set it up, this is what i have now and it throws this error, please advise

Do still need the column reference in the many-to-one tag?
Do i need to declare anything in the DEPFILESIN mapping?

org.xml.sax.SAXParseException: Attribute "property-ref" must be declared for element type "many-to-one".




<!--DDETAILS MAPPING-->
<hibernate-mapping>
<class name="DDetails" table="d_details">
<id name="id" column="id" type ="java.lang.Long" unsaved-value="null">
<generator class="native" />
</id>

<property name="filesInID" column="filesin_id" not-null="false"/>
<property name="status" column="status" not-null="false"/>

<many-to-one name="dEpFilesIn" class="DEpFilesIn" column="id" property-ref="filesin_id" not-null="false"/>
</class>
</hibernate-mapping>




<!--DEPFILESIN MAPPING-->
<hibernate-mapping>

<class name="DEpFilesIn" table="d_epfilesin">
<id name="id" column="id" type ="java.lang.Long" unsaved-value="null">
<generator class="native" />
</id>
<property name="subject" column="subject" not-null="false"/>
<set name="dDetails" inverse="true" lazy="true">
<key column="filesin_id"/>
<one-to-many class="DDetails"/>
</set>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 8:12 am 
Beginner
Beginner

Joined: Thu Aug 19, 2004 5:20 am
Posts: 25
Hi Teg

Im not quite sure how to make that change? could you please give me an example?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 8:37 am 
Regular
Regular

Joined: Wed Aug 18, 2004 5:16 am
Posts: 69
Location: Modena, Italy
Mapping:
Code:
<!--DDETAILS MAPPING-->
<hibernate-mapping>
    <class name="DDetails" table="d_details">
        <id name="id" column="id" type ="java.lang.Long" unsaved-value="null">
            <generator class="native" />
        </id>

        <property name="status" column="status" not-null="false"/>
        <many-to-one name="dEpFilesIn" class="DEpFilesIn" column="filesin_id"/>
    </class>
</hibernate-mapping>

<!--DEPFILESIN MAPPING-->
<hibernate-mapping>
    <class name="DEpFilesIn" table="d_epfilesin">
        <id name="id" column="id" type ="java.lang.Long" unsaved-value="null">
            <generator class="native" />
        </id>
        <property name="subject" column="subject" not-null="false"/>
        <set name="dDetails" inverse="true" lazy="true">
            <key column="filesin_id"/>
            <one-to-many class="DDetails"/>
        </set>
    </class>
</hibernate-mapping>

Classes:
Code:
public class DDetails implements java.io.Serializable {
   
    private Long id = null;
    private String status = null;
    private DEpFilesIn dEpFilesIn = null;
   
    public DDetails(){}
   
    public Long getId() {
        return id;
    }
   
    public void setId(Long id) {
        this.id = id;
    }
   
    public String getStatus() {
        return status;
    }
   
    public void setStatus(String status) {
        this.status = status;
    }
   
    public DEpFilesIn getDEpFilesIn() {
        return dEpFilesIn;
    }
   
    public void setDEpFilesIn(DEpFilesIn dEpFilesIn) {
        this.dEpFilesIn = dEpFilesIn;
    }
   
}

public class DEpFilesIn implements java.io.Serializable {
   
    private Long id = null;
    private String subject = null;
    private Set dDetails = new HashSet();
   
    public DEpFilesIn(){}
   
    public Long getId() {
        return id;
    }
   
    public void setId(Long id) {
        this.id = id;
    }
   
    public String getSubject() {
        return subject;
    }
   
    public void setSubject(String subject) {
        this.subject = subject;
    }
   
    public Set getDDetails() {
        return dDetails;
    }
   
    public void setDDetails(Set dDetails) {
        this.dDetails = dDetails;
    }
   
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 18 posts ]  Go to page 1, 2  Next

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.