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.  [ 6 posts ] 
Author Message
 Post subject: Trying to use code generation with eclipse 3.2
PostPosted: Fri Sep 08, 2006 1:02 pm 
Newbie

Joined: Fri Sep 08, 2006 12:44 pm
Posts: 4
Hi,

I'm a relaltive newbie to both eclipse and Hibernate.

My version of hibernate tools is 3.2.0 beta 7
Eclipse 3.2 (Callisto release)
Sql Server Express 2005.

hibernate.cfg.xml :
<?xml version="1.0" encoding="UTF-8"?>
<hibernate-configuration>
<session-factory name="sqlexpress">
<property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="hibernate.connection.password">tester</property>
<property name="hibernate.connection.url">jdbc:sqlserver://127.0.0.1:3243;instanceName=SQLEXPRESS;DatabaseName=testDB;SelectMethod=cursor</property>
<property name="hibernate.connection.username">tester</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
</session-factory>
</hibernate-configuration>

What I am attempting to do is to use the tools to creat everything I need from the database. Therefore my understanding is that I first need to creat the reverse engineering file which I did. as follows:


<?xml version="1.0" encoding="UTF-8"?>
<hibernate-reverse-engineering>
<table-filter match-catalog="testDB" match-schema="dbo" match-name=".*"/>
<table-filter match-catalog="testDB" match-schema="dbo" match-name="sysdiagrams" exclude="true"/>
</hibernate-reverse-engineering>

(NB I have problems viewing this using the hibernate editor - it throws an exception

java.lang.NullPointerException
at org.hibernate.eclipse.mapper.model.DOMReverseEngineeringDefinition.<init>(DOMReverseEngineeringDefinition.java:93)
at org.hibernate.eclipse.mapper.editors.ReverseEngineeringEditor.initSourcePage(ReverseEngineeringEditor.java:136)
at org.hibernate.eclipse.mapper.editors.ReverseEngineeringEditor.addPages(ReverseEngineeringEditor.java:84)
at org.eclipse.ui.forms.editor.FormEditor.createPages(FormEditor.java:142)
at org.eclipse.ui.part.MultiPageEditorPart.createPartControl(MultiPageEditorPart.java:276)

OK So now i try to use the code generation feature:
reverse engineer from jdbc is selected
output directory is specified, along with package info
the two detect check boxes are selected along with the generate basic ids

No matter which exporters are selected I get the following exception:

Exception while generating code Reason:
IndexOutOfBoundsException: Index:0 Size: 0


My database has no data in it just the structures at this stage.

Have I missed out something fundamentla in the way I'm trying to do this or is there something else I should be setting up.

My databse is being accessed ok because the tool to creat the reverse engineering xml shows all th etables correctly

Help much appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 08, 2006 8:03 pm 
Newbie

Joined: Fri Sep 08, 2006 12:44 pm
Posts: 4
OK I've found elsewhere that the NPE I'm getting with the reverse engineering xml editor seems to be down to a clash with XML Buddy which I have installed.

Still no further understanding why the code generation is falling over though.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 10, 2006 9:32 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
there is a stupid bug about many-to-many detection that sometimes kicks in.

if you remove the checkbox for manytomany it should work.

let me know if it doesn't help.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 10, 2006 3:28 pm 
Newbie

Joined: Fri Sep 08, 2006 12:44 pm
Posts: 4
Thanks Max, deselecting the many to many option certainly allowed it to get further.

I'm now getting a different exception while generating code:

org.hibernate.cfg.JDBCBinderException: Duplicate class name 'com.malcooke.sql.CheckConstraints' generated for 'org.hibernate.mapping.Table(testDB.sys.check_constraints)'. Same name where generated for 'org.hibernate.mapping.Table(testDB.sys.check_constraints)'
<No message>

I'm not sure what this might be as the only schema I'm pulling back from the db is the dbo schema (I believe) and excluding the stuff relating to sysdiagrams.

my reverse engineering xml is as follows

<hibernate-reverse-engineering>
<table-filter match-catalog="testDB" match-schema="dbo" match-name=".*"/>
<table-filter match-catalog="testDB" match-schema="dbo" match-name="sysdiagrams" exclude="true"/>
</hibernate-reverse-engineering>


Just one thought I am using the SQLServer dialect - which I presume is the right one for SQL Server Express 2005 - is that correct?

Thanks for your help so far.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 10, 2006 3:33 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you should try only to include your schema or at least exclude those system tables.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 11, 2006 5:55 am 
Newbie

Joined: Fri Sep 08, 2006 12:44 pm
Posts: 4
OK Thanks for your help Max.

I finally got the code generation working by recreating the reverse engineer xml file so that each table was specified explicitly and no wild cards were used.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.