-->
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: reset list hibernate
PostPosted: Wed Dec 12, 2012 4:56 am 
Newbie

Joined: Wed Dec 12, 2012 4:44 am
Posts: 1
HI;

i have two department's in the department table of my database. a department contains a list of velden. but on the second department the list with velden has first all null values and then the values that i need. it looks like the list of velden is not reset after the getting the first list of velden. this is an image of the variables

Image

i think it's a mapping issue but i cant find the solution.

this is the mapping of departments

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Dec 11, 2012 9:37:04 PM by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
    <class name="be.centric.model.Departments" table="departments" catalog="purespai-8">
        <id name="id" type="int">
            <column name="Id" />
            <generator class="assigned" />
        </id>
        <many-to-one name="stores" class="be.centric.model.Stores" fetch="select">
            <column name="Stores_Id" not-null="true" />
        </many-to-one>
        <property name="naam" type="string">
            <column name="Naam" length="45" />
        </property>
        <property name="breedte" type="java.lang.Integer">
            <column name="Breedte" />
        </property>
        <property name="lengte" type="java.lang.Integer">
            <column name="Lengte" />
        </property>
        <set name="slideshowses" inverse="true">
            <key>
                <column name="Departments_Id" not-null="true" />
            </key>
            <one-to-many class="be.centric.model.Slideshows" />
        </set>
        <set name="veldens" inverse="true">
            <key>
                <column name="Departement" />
            </key>
            <one-to-many class="be.centric.model.Velden" />
        </set>
    </class>
</hibernate-mapping>


the mapping of velden

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Dec 11, 2012 9:37:04 PM by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
    <class name="be.centric.model.Velden" table="velden" catalog="`purespai-8`">
        <id name="id" type="java.lang.Integer">
            <column name="Id" />
            <generator class="identity" />
        </id>
        <many-to-one name="status" class="be.centric.model.Status" fetch="select">
            <column name="Status" />
        </many-to-one>
        <many-to-one name="departments" class="be.centric.model.Departments" fetch="select">
            <column name="Departement" />
        </many-to-one>
        <property name="x" type="java.lang.Integer">
            <column name="X" />
        </property>
        <property name="y" type="java.lang.Integer">
            <column name="Y" />
        </property>
        <property name="rekId" type="int">
            <column name="rekId" not-null="true" />
        </property>
        <set name="vaks" inverse="true">
            <key>
                <column name="Veld" />
            </key>
            <one-to-many class="be.centric.model.Vak" />
        </set>
    </class>
</hibernate-mapping>


departments.java
Code:
package be.centric.model;
// Generated Nov 24, 2012 11:05:38 AM by Hibernate Tools 3.2.1.GA


import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
* Departments generated by hbm2java
*/
public class Departments  implements java.io.Serializable {


     private int id;
     private Stores stores;
     private String naam;
     private Integer breedte;
     private Integer lengte;
     private Set slideshowses = new HashSet(0);
     private List<Velden> veldens = new ArrayList<Velden>();

    public Departments() {
    }

   
    public Departments(int id, Stores stores) {
        this.id = id;
        this.stores = stores;
    }
    public Departments(int id, Stores stores, String naam, Integer breedte, Integer lengte, Set slideshowses, List veldens) {
        veldens = new ArrayList<Velden>();
       this.id = id;
       this.stores = stores;
       this.naam = naam;
       this.breedte = breedte;
       this.lengte = lengte;
       this.slideshowses = slideshowses;
       this.veldens = veldens;
    }
   
    public int getId() {
        return this.id;
    }
   
    public void setId(int id) {
        this.id = id;
    }
    public Stores getStores() {
        return this.stores;
    }
   
    public void setStores(Stores stores) {
        this.stores = stores;
    }
    public String getNaam() {
        return this.naam;
    }
   
    public void setNaam(String naam) {
        this.naam = naam;
    }
    public Integer getBreedte() {
        return this.breedte;
    }
   
    public void setBreedte(Integer breedte) {
        this.breedte = breedte;
    }
    public Integer getLengte() {
        return this.lengte;
    }
   
    public void setLengte(Integer lengte) {
        this.lengte = lengte;
    }
    public Set getSlideshowses() {
        return this.slideshowses;
    }
   
    public void setSlideshowses(Set slideshowses) {
        this.slideshowses = slideshowses;
    }
   public List<Velden> getVeldens(){
        return  veldens;
    }

   
    public void setVeldens(List<Velden> veldens) {
       
        this.veldens = veldens;
       
       
    }




}




department dao

Code:
    public Iterable<Departments> fetchAll() {
       
       
          Session session = HibernateUtil.getSessionFactory().openSession();
             

           Iterable<Departments> departments = null;
                try {

                     
                Criteria criteria = session.createCriteria(Departments.class);
               
             

                 departments = criteria.list();

                } catch (HibernateException e) {

                        e.printStackTrace();
                } finally {
                         session.flush();
                       
                }

        return departments;
       
    }


you help is really appreciated
-Jonas


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.