-->
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: one-to-many in a bag => always null
PostPosted: Thu Jun 24, 2004 12:10 pm 
Newbie

Joined: Thu Jun 24, 2004 11:39 am
Posts: 2
Location: Belgium
* Hibernate Version 2.1.4
* Postgresql 7.4

* Mapping documents:
-
Code:
   <?xml version="1.0"?>
     <!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

    <hibernate-mapping package="com.useitgroup.ui2005.domain">
   <class name="Land" table="Land">
           <id name="id" column="id" type="long">
                        <generator class="native"/>
                </id>

      <property name="naam" type="string"/>
      <property name="code" type="string"/>
               
                <bag name="plaatsen" inverse="true" lazy="false" cascade="save-update">
                    <key column="landId"/>
                    <one-to-many class="Plaats"/>
                </bag>
   </class>
    </hibernate-mapping>


-
Code:
<?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

    <hibernate-mapping package="com.useitgroup.ui2005.domain">
   <class name="Plaats" table="Plaats">
           <id name="id" column="id" type="long">
                        <generator class="native"/>
                </id>

      <property name="postcode" type="string"/>
      <property name="gemeente" type="string"/>
                <many-to-one name="land" column="landId"/>
   </class>
    </hibernate-mapping>


So the same in a schema here we have 2 tables:
[Plaats]..............[Land]
Id.............. /--->.Id
LandId.----/........Naam
Postcode............Code
Gemeente

* [code] private void PostcodeTest()
{
Configuration cfg = new Configuration();
SessionFactory sf = null;
Session s = null;
Transaction tx;
List landen;
Plaats[] plaatsen;
ListIterator listiterator;
Land land;
Plaats plaats;
int t;

try
{
cfg.addClass(Plaats.class);
cfg.addClass(Land.class);
cfg.setProperty(Environment.HBM2DDL_AUTO, "create");
cfg.setProperty(Environment.SHOW_SQL, "true");
sf = cfg.buildSessionFactory();
s = sf.openSession();

tx = s.beginTransaction();
land = new Land("Belgi

_________________
Greetings
Spike


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 24, 2004 12:25 pm 
Senior
Senior

Joined: Wed Aug 27, 2003 4:08 am
Posts: 178
Location: Wiesbaden, Germany
What is in the database?
was landId of Plaats set properly?

_________________
Got new hibernate xdoclet plugin? http://www.sourceforge.net/projects/xdoclet-plugins/
... Momentan auf der Suche nach neuen Projekt ode Festanstellung....


Top
 Profile  
 
 Post subject: yes
PostPosted: Thu Jun 24, 2004 5:08 pm 
Newbie

Joined: Thu Jun 24, 2004 11:39 am
Posts: 2
Location: Belgium
all Id's and foreign keys where properly stored

_________________
Greetings
Spike


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.