-->
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.  [ 23 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Customizing property name
PostPosted: Thu Apr 06, 2006 8:09 am 
Regular
Regular

Joined: Mon Mar 06, 2006 6:18 am
Posts: 95
Location: Bern, Switzerland
Hello

i just defined my reveng.xml file to generate the Mapping Files and Model classes.

How can i define a propety name for a foreign key?? My table schema for the TBENUTZER looks like that:

Code:
<table schema="NAJSRE7_WEB" name="TBENUTZER" class="najs.model.Benutzer">
      <primary-key>
         <generator class="sequence">
            <param name="sequence">SEQ_TBENUTZER</param>
         </generator>
         <column name="ILAUFNUMMER" property="id" />
      </primary-key>

      <column name="SBENUTZERNAME" jdbc-type='' property="benutzerName" />
      <column name="SPASSWORT" jdbc-type='' property="passwort" />
      <column name="SEMAIL" jdbc-type='' property="eMail" />
      <column name="DLASTLOGIN" jdbc-type='' property="lastLogin" />
      <column name="IANZLOGIN" jdbc-type='' property="anzahlLogin" />
      <column name="SMUTUSER" jdbc-type='' property="mutUser" />
      <column name="SSTVUSER" jdbc-type='' property="stvUser" />
      <column name="DMUTDAT" jdbc-type='' property="mutDat" />
      <column name="FK_TPER_IPERSNR" jdbc-type='' property="personId" />
      <column name="FK_TBENUSTAT_ISTATUS" jdbc-type='' property="benutzerStatus" type="najs.model.BenutzerStatus" />
   </table>


If i generate the Beutzer.java file now, there is no property calles benutzerStatus. The propery look like that:
Code:
private BenutzerStatus tbenutzerStatus;

public BenutzerStatus getTbenutzerStatus() {
        return this.tbenutzerStatus;
    }
   
    public void setTbenutzerStatus(BenutzerStatus tbenutzerStatus) {
        this.tbenutzerStatus = tbenutzerStatus;
    }


How can i change that is called benutzerStatus like defined in the xml file??

It's also wrong in the mapping file:
Code:
  <many-to-one name="tbenutzerStatus" class="najs.model.BenutzerStatus" fetch="select">
            <column name="FK_TBENUSTAT_ISTATUS" precision="1" scale="9" not-null="true" />
        </many-to-one>



Any help appreciated

Thanks
Angela


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 06, 2006 9:10 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
latest cvs allows you to do:

Code:
<foreign-key constraint-name="child_to_parent">
<many-to-one property="propertyParent"/>
<set property="propertyChildren"/>
</foreign-key>

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 06, 2006 9:57 am 
Regular
Regular

Joined: Mon Mar 06, 2006 6:18 am
Posts: 95
Location: Bern, Switzerland
max wrote:
latest cvs allows you to do:

Code:
<foreign-key constraint-name="child_to_parent">
<many-to-one property="propertyParent"/>
<set property="propertyChildren"/>
</foreign-key>


oh great! is there a nightly build somewhere available? because I can't do a CSV checkout here...all ports are closed :-(

Another question...What's about the inverse entries that will be created, like:

Code:
  <set name="tzugangs" inverse="true">
            <key>
                <column name="FK_TBENU_ILAUFNR" precision="1" scale="9" />
            </key>
            <one-to-many class="najs.model.Zugang" />
        </set>


Is there also a way to define the property/set name??

Thanks!! Angela


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 06, 2006 10:02 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
read the xml snippet again ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 06, 2006 10:05 am 
Regular
Regular

Joined: Mon Mar 06, 2006 6:18 am
Posts: 95
Location: Bern, Switzerland
max wrote:
read the xml snippet again ;)


oh sorry ;-) i've seen it now! thanks a lot!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 13, 2006 3:48 am 
Regular
Regular

Joined: Mon Mar 06, 2006 6:18 am
Posts: 95
Location: Bern, Switzerland
max wrote:
latest cvs allows you to do:

Code:
<foreign-key constraint-name="child_to_parent">
<many-to-one property="propertyParent"/>
<set property="propertyChildren"/>
</foreign-key>


i'm having some problems to compile the newest hibernate-tools version with eclipse :-( first i had to comment out in ejb/build.xml:

Code:
<ant inheritall="false" dir="${basedir}/doc/reference"/>


because of this error:

Code:
dist:
  [taskdef] Could not load definitions from resource clovertasks. It could not be found.

BUILD FAILED
C:\temp\HibernateExt\build.xml:25: The following error occurred while executing this line:
C:\temp\HibernateExt\ejb\build.xml:206: The following error occurred while executing this line:
C:\temp\HibernateExt\ejb\doc\reference\build.xml:5: Cannot find C:\temp\Hibernate3\doc\reference/build.xml imported from C:\temp\HibernateExt\ejb\doc\reference\build.xml



now i'm getting this error:

Code:
compile:
    [javac] Compiling 165 source files to C:\temp\HibernateExt\metadata\build\classes
    [javac] C:\temp\HibernateExt\metadata\src\java\org\hibernate\reflection\java\Comprehension.java:20: incompatible types
    [javac] found   : java.lang.Object
    [javac] required: T
    [javac] return collection.getClass().newInstance();
    [javac] ^
    [javac] Note: Some input files use unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.
    [javac] 1 error


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 13, 2006 5:12 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
if i remember correctly the new build docs just shows that you should do:

cd hibernateext/tools

..\build

which will refrain it from having to build the other projects which is where you are having problems.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 13, 2006 5:33 am 
Regular
Regular

Joined: Mon Mar 06, 2006 6:18 am
Posts: 95
Location: Bern, Switzerland
max wrote:
if i remember correctly the new build docs just shows that you should do:

cd hibernateext/tools

..\build

which will refrain it from having to build the other projects which is where you are having problems.


hello

i was able to build it with eclipse now:
Code:
common-build.dist:
      [zip] Building zip: C:\temp1\HibernateExt\tools\target\hibernate-tools-3.1.0beta4.zip
      [tar] Building tar: C:\temp1\HibernateExt\tools\target\hibernate-tools-3.1.0beta4.tar.gz
      [tar] Entry: hibernate-tools-3.1.0beta4/doc/api/org/hibernate/cfg/reveng/DelegatingReverseEngineeringStrategy.html longer than 100 characters.
      [tar] Resulting tar file can only be processed successfully by GNU compatible tar commands
      [tar] Entry: hibernate-tools-3.1.0beta4/doc/api/org/hibernate/tool/hbm2x/visitor/HBMTagForPersistentClassVisitor.html longer than 100 characters.
      [tar] Entry: hibernate-tools-3.1.0beta4/src/org/hibernate/tool/hbm2x/visitor/HBMTagForPersistentClassVisitor.java longer than 100 characters.
dist:
BUILD SUCCESSFUL


But i don't know if these are the eclipse plugin now! How can i build the eclipse plugin, in order to use the new functions you mentioned above?

thanks angela


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 13, 2006 6:00 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you dont need to build the eclipse plugins to use it. just look at the unitests.

if you want the eclipse plugins i recommend to use the nightly builds instead since building eclipse PDE is a nigthmare.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 13, 2006 6:21 am 
Regular
Regular

Joined: Mon Mar 06, 2006 6:18 am
Posts: 95
Location: Bern, Switzerland
:-) you're right it's much easier this way! thanks...

i tried out the foreign-key element and get this error:

Code:
            <foreign-key foreign-table="TBENUTZER_STATUS">
         <column-ref  local-column="FK_TBENUSTAT_ISTATUS" foreign-column="ISTATUS"/>
         <many-to-one property="benutzerStatus"/>
      </foreign-key>   


Code:
Caused by: org.xml.sax.SAXParseException: Element type "many-to-one" must be declared.


is there somewhere already a small documentation about this available or not yet?

i'll check the installation of the nightly build again..maybe there is a problem because there are 2 versions of this plugin now

thanks a lot
angela


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 13, 2006 8:00 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
is this from the nightly build when using eclipse ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 13, 2006 8:12 am 
Regular
Regular

Joined: Mon Mar 06, 2006 6:18 am
Posts: 95
Location: Bern, Switzerland
max wrote:
is this from the nightly build when using eclipse ?


yep, the nightly build with eclipse 3.1. the foreign-key entry looks like that now

Code:
      <foreign-key constraint-name="benutzerStatus" foreign-table="TBENUTZER_STATUS">
         <column-ref  local-column="FK_TBENUSTAT_ISTATUS" foreign-column="ISTATUS"/>
         <many-to-one property="benutzerStatus"/>
      </foreign-key>


While code generating i get a nullpointer-exception! unfortunatley i see no entry in the eclipse log file. i think i still habe conflicts with the plugin..try it with installing all new...

angela


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 13, 2006 8:47 am 
Regular
Regular

Joined: Mon Mar 06, 2006 6:18 am
Posts: 95
Location: Bern, Switzerland
hmm didn't succed with installing new...but now i see an entry in the logfile:
Code:

!ENTRY org.eclipse.wst.sse.ui 4 4 2006-04-13 14:40:02.695
!MESSAGE problem with as-you-type validation
!STACK 0
java.lang.NullPointerException
   at org.eclipse.wst.sse.ui.internal.reconcile.StructuredRegionProcessor.process(StructuredRegionProcessor.java:75)
   at org.eclipse.wst.sse.ui.internal.reconcile.StructuredRegionProcessor.process(StructuredRegionProcessor.java:62)
   at org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor.run(DirtyRegionProcessor.java:375)
   at org.eclipse.core.internal.jobs.Worker.run(Worker.java:76)
!SESSION 2006-04-13 14:44:02.645 -----------------------------------------------
eclipse.buildId=M20050929-0840
java.version=1.5.0_06
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_CH
Command-line arguments:  -os win32 -ws win32 -arch x86



do you have an idea about this error?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 13, 2006 9:14 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
that error is a WTP error, not related to the error found when doing code generation.

btw. it is an error that occur when you are running the codegeneration, not just a warning in the xml editor ? (the last one can occur if the bundled dtd in the plugin is not uptodate yet).

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 13, 2006 10:42 am 
Regular
Regular

Joined: Mon Mar 06, 2006 6:18 am
Posts: 95
Location: Bern, Switzerland
finally everything is working again, inluding the nightly build :-)

just one last question. i'm now able the define the forein key for the table TBENUTZER:

Code:
<column name="FK_TBENUSTAT_ISTATUS" jdbc-type='' property="benutzerStatus" type="najs.model.BenutzerStatus" />
      <foreign-key constraint-name="PK_TBENUTZER_STATUS" foreign-table="TBENUTZER_STATUS">
         <column-ref  local-column="FK_TBENUSTAT_ISTATUS" foreign-column="ISTATUS" />
         <many-to-one property="benutzerStatus"/>
      </foreign-key>


Then the model class has a property
Code:
private BenutzerStatus benutzerStatus;


which is what i wanted :-)

The table TZUGANG has also a foreign key which points to the TBENUTZER table.It's defined like that in the TZUGANG table mapping (reveng file):

Code:
<column name="FK_TBENU_ILAUFNR" jdbc-type='' property="benutzer" type="najs.model.Benutzer" />
      <foreign-key constraint-name="PK_TBENUTZER" foreign-table="TBENUTZER">
         <column-ref  local-column="FK_TBENU_ILAUFNR" foreign-column="ILAUFNUMMER"/>
         <many-to-one property="benutzer"/>
      </foreign-key>


The model class Zugang.java is created and has a property
Code:
private Benutzer benutzer;
:-) till here everything is ok.

if i take a look at the Benutzer class again, i can see the inverse mapping to the table TZUGANG and there are suddenly two more properties defined:

Code:
private Set tzugangsForFkTbenuIlaufnr = new HashSet(0);

   private Set tzugangsForFkTbenuIlaufnr_1 = new HashSet(0);


Why are there two of these properties? And how can i define the property name? Did i something wrong in the reverse engineering file?

Kind Regards and Happy Easter!
Angela


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