-->
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.  [ 13 posts ] 
Author Message
 Post subject: Getting Hibernate tools to do something
PostPosted: Thu Oct 30, 2008 2:16 am 
Beginner
Beginner

Joined: Tue Oct 28, 2008 6:41 pm
Posts: 20
Hi,
I have been trying in vain to get hibernate tools to do something/anything useful for several days. It is incredibly frustrating because if it worked as intended ,it would be huge time saver.

I've gone through the Hibernate documentation several times and it still does not work the way the documentation describes.

Problem 1)
I have tried to create mapping files from pojo's and all I get is a new file with just a standard xml header and the name of the class but no mappings even thoguh the java file I've pointed to is a standard ajva object with propertys -getters and setters.

Problem 2)
I have tried to create a new project and reverse engineer it from scratch and I get the message below. The reveng file seems to be seeing the database schema ok .

I have no idea of what this message below means or how to resolve it. a snippet of the reveng.xml file is below .

I am using the hiberante 3.2 eclipse plug in. It seems like it installed ok.

Also does anybody know if you have to type in a jdbc type for every column ?

If anybody can shed any light on this ,it would be really helpful .Thanks.

-------------
org.hibernate.console.HibernateConsoleRuntimeException: Could not create or find org.hibernate.cfg.reveng.ReverseEngineeringStrategyUtil with default no-arg constructor
Could not create or find org.hibernate.cfg.reveng.ReverseEngineeringStrategyUtil with default no-arg constructor
java.lang.IllegalAccessException: Class org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate can not access a member of class org.hibernate.cfg.reveng.ReverseEngineeringStrategyUtil with modifiers "private"
Class org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate can not access a member of class org.hibernate.cfg.reveng.ReverseEngineeringStrategyUtil with modifiers "private"
java.lang.IllegalAccessException: Class org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate can not access a member of class org.hibernate.cfg.reveng.ReverseEngineeringStrategyUtil with modifiers "private"
Class org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate can not access a member of class org.hibernate.cfg.reveng.ReverseEngineeringStrategyUtil with modifiers "private"
--------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >

<hibernate-reverse-engineering>
<type-mapping>
<sql-type jdbc-type="VARCHAR" hibernate-type="string"></sql-type>
<sql-type jdbc-type="SMALLINT" hibernate-type="java.lang.Short"
not-null="false">
</sql-type>
<sql-type jdbc-type="DOUBLE" hibernate-type="java.lang.Double"
precision="15" scale="5" not-null="false">
</sql-type>
</type-mapping>
<table-filter match-schema="lahman54" match-name=".*" />
<table catalog="lahman54" name="pitching" class="Pitching">
<primary-key>
<generator class="assigned"></generator>
</primary-key>
<column name="playerID" jdbc-type=''></column>
<column name="yearID" jdbc-type=''></column>
<column name="stint" jdbc-type=''></column>
<column name="teamID" jdbc-type=''></column>
<column name="lgID" jdbc-type=''></column>
<column name="W" jdbc-type=''></column>
<column name="L" jdbc-type=''></column>
<column name="G" jdbc-type=''></column>
<column name="GS" jdbc-type=''></column>
<column name="CG" jdbc-type=''></column>
<column name="SHO" jdbc-type=''></column>
<column name="SV" jdbc-type=''></column>
<column name="IPouts" jdbc-type=''></column>
<column name="H" jdbc-type=''></column>
<column name="ER" jdbc-type=''></column>
<column name="HR" jdbc-type=''></column>
<column name="BB" jdbc-type=''></column>
<column name="SO" jdbc-type=''></column>
<column name="BAOpp" jdbc-type=''></column>
<column name="ERA" jdbc-type=''></column>
<column name="IBB" jdbc-type=''></column>
<column name="WP" jdbc-type=''></column>
<column name="HBP" jdbc-type=''></column>
<column name="BK" jdbc-type=''></column>
<column name="BFP" jdbc-type=''></column>
<column name="GF" jdbc-type=''></column>
<column name="R" jdbc-type=''></column>
<column name="SH" jdbc-type=''></column>
<column name="SF" jdbc-type=''></column>
<column name="GIDP" jdbc-type=''></column>
</table>
--------------


Top
 Profile  
 
 Post subject: Re: Getting Hibernate tools to do something
PostPosted: Fri Oct 31, 2008 8:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
pauln wrote:
Hi,
I have been trying in vain to get hibernate tools to do something/anything useful for several days. It is incredibly frustrating because if it worked as intended ,it would be huge time saver.


sorry to hear that it doesn't work for you..lets see what we can do.

Quote:
Problem 1)
I have tried to create mapping files from pojo's and all I get is a new file with just a standard xml header and the name of the class but no mappings even thoguh the java file I've pointed to is a standard ajva object with propertys -getters and setters.


The wizard doesn't do more than that at the moment i'm afraid (i.e. besides creating the skeleton for a hbm.xml).

Quote:
Also does anybody know if you have to type in a jdbc type for every column ?


No, it just picks it up from the database if you don't specify anything.

Your reveng.xml can be completely empty and it would reverse engineer the whole database.

Quote:
-------------
org.hibernate.console.HibernateConsoleRuntimeException: Could not create or find org.hibernate.cfg.reveng.ReverseEngineeringStrategyUtil with default no-arg constructor


You have set the reverse engineering strategy to point to an class that does not implement IReverseEngineeringStrategy - I assume you simply have done that by error. Just leave the field blank since it is purely optional.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Getting Hibernate tools to do something
PostPosted: Fri Oct 31, 2008 3:29 pm 
Beginner
Beginner

Joined: Tue Oct 28, 2008 6:41 pm
Posts: 20
Thanks Max, for clearing up the question about the *.hbm.xml file creation dialogue. I was wondering if I was missing a setting in the dialogue or something.

I still have some questions about the code generation process.

1)
It appears you have to create a new console configuration for each project. I tried to link to a previous console configuration for a project that was open in eclipse and it couldn't find the Hibernate.cf.xml . The result is I end up with an ever increasing list of console configurations that you can't edit or remove.This seems to be more of an irritating thing with eclipse than Hibernate .

2) I tried to use code generation on the following file and got a generic null pointer exception .

java.lang.NullPointerException<No message>

In the code generation dialogue,I am pointing to an empty revenge.xml file(below) .

The database connection is working when I click refresh in the the reveng editor .

Do you have an idea of what I'm missing?
Thanks,
Paul

------------------------
hibernate.reveng.xml
--------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >

<hibernate-reverse-engineering>

---------------------
hibernate.cfg.xml
--------------------

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">losers</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/lahman54</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.default_catalog">lahman54</property>
<property name="hibernate.default_schema">lahman54</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<mapping resource="Allstar.hbm.xml"/>
<mapping resource="Awardsmanager.hbm.xml"/>
<mapping resource="Awardsplayer.hbm.xml"/>
<mapping resource="Awardssharemanager.hbm.xml"/>
<mapping resource="Awardsshareplayer.hbm.xml"/>
<mapping resource="Batting.hbm.xml"/>
<mapping resource="Battingpost.hbm.xml"/>
<mapping resource="Fielding.hbm.xml"/>
<mapping resource="Fieldingof.hbm.xml"/>
<mapping resource="Fieldingpost.hbm.xml"/>
<mapping resource="Halloffame.hbm.xml"/>
<mapping resource="Manager.hbm.xml"/>
<mapping resource="Managershalf.hbm.xml"/>
<mapping resource="Master.hbm.xml"/>
<mapping resource="Pitching.hbm.xml"/>
<mapping resource="Pitchingpost.hbm.xml"/>
<mapping resource="Salary.hbm.xml"/>
<mapping resource="Team.hbm.xml"/>
<mapping resource="Teamshalf.hbm.xml"/>
<mapping resource="Seriespost.hbm.xml"/>
<mapping resource="Teamsfranchis.hbm.xml"/>
<mapping resource="Team.hbm.xml"/>
</session-factory>
</hibernate-configuration>

</hibernate-reverse-engineering>


Top
 Profile  
 
 Post subject: Re: Getting Hibernate tools to do something
PostPosted: Fri Oct 31, 2008 7:17 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
pauln wrote:
1)
It appears you have to create a new console configuration for each project. I tried to link to a previous console configuration for a project that was open in eclipse and it couldn't find the Hibernate.cf.xml . The result is I end up with an ever increasing list of console configurations that you can't edit or remove.This seems to be more of an irritating thing with eclipse than Hibernate .


You don't have to create a new console configuration for each project; projects can share console configurations if needed.

And you can edit/remove console configurations in the Hibernate Console configuration view (see in the Hibernate perspective)

Quote:
2) I tried to use code generation on the following file and got a generic null pointer exception .

java.lang.NullPointerException<No message>


What is the full stack trace ?

Anything in the error log ?

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Getting Hibernate to do something
PostPosted: Fri Oct 31, 2008 8:43 pm 
Beginner
Beginner

Joined: Tue Oct 28, 2008 6:41 pm
Posts: 20
I finally saw how to view the configurations Window ->show view . That clears that part up.

As far as i can tell that is the full stack trace.
java.lang.NullPointerException<No message>

I can't find any logging action/files
I have logforj in my build path and nothing appears in the eclipse console at the bottom.


This is the log4jproperties file located in my project root directory.
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %5p %c{1}:%L - %m%n
### direct messages to file hibernate.log ###
#log4j.appender.file=org.apache.log4j.FileAppender
#log4j.appender.file.File=hibernate.log
#log4j.appender.file.layout=org.apache.log4j.PatternLayout
#log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %5p %c{1}:%L - %m%n
log4j.rootLogger=error, stdout
log4j.logger.org.hibernate.SQL=debug
log4j.logger.org.hibernate.type=debug


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 03, 2008 7:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Look in the Error Log view - it should have the full info.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Hibernate issues
PostPosted: Wed Nov 05, 2008 12:17 am 
Beginner
Beginner

Joined: Tue Oct 28, 2008 6:41 pm
Posts: 20
This is what I have in my error file (below). It seems to be a problem with a foreign key mapping .

It doesn't really tell me a lot as the database itself is flat with no foreign keys.

I got this to work about 6 months ago using hibernate version 2 and middlegen . It was a hassle because nothing worked with hibernate 3 , but it in the end, it did what I expected . It created mapping files, pojos etc,plus it generated generic jsps.



eclipse.buildId=M20080221-1800
java.version=1.6.0_05
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Command-line arguments: -os win32 -ws win32 -arch x86
This is a continuation of log file C:\_eclipseworkspace\.metadata\.bak_0.log
Created Time: 2008-10-31 15:21:47.437

Error
Fri Oct 31 17:41:53 PDT 2008
java.lang.NullPointerException: <no message>

java.lang.NullPointerException
at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:77)
at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:73)
at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1263)
at org.hibernate.cfg.JDBCMetaDataConfiguration.secondPassCompileForeignKeys(JDBCMetaDataConfiguration.java:33)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1170)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate$2.execute(CodeGenerationLaunchDelegate.java:315)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:65)
at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:88)
at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.buildConfiguration(CodeGenerationLaunchDelegate.java:281)
at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.runExporters(CodeGenerationLaunchDelegate.java:214)
at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.launch(CodeGenerationLaunchDelegate.java:134)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:759)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:608)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:899)
at org.eclipse.debug.internal.ui.DebugUIPlugin$7.run(DebugUIPlugin.java:1102)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 05, 2008 6:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well for ForeignKey.alignColumns to be called some foreign key must be in either the database or the reveng.xml ...

Any way you could reduce it to a simple testcase we can reproduce on ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 10, 2008 10:10 pm 
Beginner
Beginner

Joined: Tue Oct 28, 2008 6:41 pm
Posts: 20
Hi,

The problem seems to be one of the tables in the database. I have tried it on a couple different tables using only one table at a time in the reveng file and the code generation produced the a java and hbm files that were expected. Apparently ,one of the tables has something in it that is causing the null pointer exception.

Thanks for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 11, 2008 1:21 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
okey - so what is the structure of that table ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 11, 2008 2:48 pm 
Beginner
Beginner

Joined: Tue Oct 28, 2008 6:41 pm
Posts: 20
I'm not sure.

There are 22 tables and some of them are quite large . When i broke the reveng.xml file down into progressivley smaller batches,it processed them all as expected. I broke the batches first into to a group of 10, then two groups of 5 ,then the last two, and it seemed to work.

The null pointer problem occured when I tried to process them all at once. It would get to 19% and then the error would occur. Maybe it's a memory issue on the computer.

After it runs, there is a weird problem in that several of the tables are flat files that were imported from Access into MySql and do not have a primary key. When the ***.hbm.xml file gets created ,it makes every field a key field.

Is this the default behaviour if the reveng.xml file does not have an explicit primary key set for a given table?

example:
<key-property name="lahmanId" type="java.lang.Short">
<column name="lahmanID" />
</key-property>
<key-property name="playerId" type="string">
<column name="playerID" length="10" />
</key-property>
<key-property name="managerId" type="string">
<column name="managerID" length="10" />
</key-property>
<key-property name="hofId" type="string">
<column name="hofID" length="10" />
</key-property>
etc...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 13, 2008 2:27 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
that is the default behavior since an entity requires and id and without a key it must be the complete set of columns.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 13, 2008 2:38 pm 
Beginner
Beginner

Joined: Tue Oct 28, 2008 6:41 pm
Posts: 20
That makes sense.
Thanks for all your help.


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