-->
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.  [ 8 posts ] 
Author Message
 Post subject: generator doesen't respect schema of table
PostPosted: Mon May 03, 2004 9:05 am 
Newbie

Joined: Mon Apr 26, 2004 5:17 pm
Posts: 13
Hi there,

Is it true, that a generator doesen't respects the schema from the class?
for example:

Code:
<hibernate-mapping package="ch.globus.nglr" >
   <class name="NglrHeader" table="NGLR_HEADER"    schema="XXX">
      <id
         column="HEADERID"
         length="10"
         name="headerId"
         type="int"
         unsaved-value="0"
      >
         <generator class="increment" />
   </id>
      <property
         column="COMPANY"
         length="5"
         name="company"
         not-null="true"
         type="int"
       />


The error comes like this: SQL0204N "DB2ADMIN.NGLR_HEADER" is an undefined name.

After changing to:

Code:
<hibernate-mapping package="ch.globus.nglr" >
   <class name="NglrHeader" table="NGLR_HEADER" schema="XXX">
      <id
         column="HEADERID"
         length="10"
         name="headerId"
         type="int"
         unsaved-value="0"
      >
         <generator class="increment" >
         <param name="schema">XXX</param>
         </generator>
      </id>
      <property
         column="COMPANY"
         length="5"
         name="company"
         not-null="true"
         type="int"
       />


It works...

Is this the real case?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 03, 2004 7:28 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
This is a known bug and won't be fixed (too uggly).

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 04, 2004 4:45 am 
Newbie

Joined: Mon Apr 26, 2004 5:17 pm
Posts: 13
Ok...

So what's the best workaround then for this case?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 04, 2004 4:47 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Exactly the one you posted already


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 04, 2004 4:56 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Try a custom generator taking schema as a parameter

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 04, 2004 5:33 am 
Newbie

Joined: Mon Apr 26, 2004 5:17 pm
Posts: 13
Can i set in this case the schema for the generator at runtime?

Because i get the schemas from an other resource depending of the company i'm working on at runtime.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 05, 2004 11:57 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Kind of
By reading the DOM and updating it before sending it to configure(DOM).
Not that elegent however

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 05, 2004 12:57 pm 
Beginner
Beginner

Joined: Thu Jan 22, 2004 8:22 pm
Posts: 48
I ran into the same difficulty using DB2 sequences and also have the problem that the schema can be differant in differant environments. My solution was a hacked version of the DB2Dialect class. It's not a perfect solution. After using it for awhile I discovered it work somewhat by happenstance but in our environment it does work. It doesn't use the schema from the table but from the hibernate configuration. If you'd like I can send you a patch against the 2.1 for this. It might also work for your environment.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.