-->
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.  [ 11 posts ] 
Author Message
 Post subject: Bug in Middlegen r5 Plugin
PostPosted: Fri Aug 06, 2004 6:18 am 
Regular
Regular

Joined: Tue Mar 23, 2004 2:10 am
Posts: 51
Hi,
I migrated from r4 hibernate plugin to newly released to r5 plugin. I am using Oracle and we specify some tables in build.xml file for which mapping should be generated. Now when i used this new plugin version then if i dont specify any tables it runs but when i specify single table (with uppercase and no problem in table name and its primaty key) in build.xml it generates error of OutOfMemory. I wonder why it runs for 500 tables and not run for a single table. The build.xml is correct and running perfectly well in r4 release. Please reply me asap.

Regards,
Shoaib Akhtar


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 08, 2004 1:54 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Hmmm... Please supply the example ant script that produces the problem and I will see if I can work it out.

BTW: R5 is using MIddlegen 2.1 beta (though I expected it to be totally solid).


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 08, 2004 3:59 am 
Regular
Regular

Joined: Tue Mar 23, 2004 2:10 am
Posts: 51
Hello,
Thanks for your reply. I am using the same ant script that is distributed with MiddleGen r5 plugin (its home directory.) There is only one difference i am using Oracle 9.2.0 as database so i have changed hsql.xml to point towards oracle.xml and also i have specified the table i am using. I am using ojdbc14.jar as database driver classes. As i told earlier everything is working fine if i generate mapping for the whole databse. Only when i specified specific table ( which exist , i am using upper case for table name as recommended for oracle database and primary key is also correct. The same table and setting were working fine in r4 of the plugin version. My database conatain so many table (almost 700) and it is difficult to visualize them all at the same time. I am only specifying one table in this file. Kindly help me asap and check this as i require the new versions feature (equals and hashcode) in my application. I have mentioned all the things but even then i am pasting my ant.xml and oracle.xml here for reference. The ojdbc14.jar driver is in the lib folder.

<?xml version="1.0"?>

<!--
This is a testing platform for the middlegen hibernate plugin. It is a stripped
down version of the samples application. At the moment it is only concerned
with the generation of the mapping documents so that various tests etc can be
done on the generated package.

David Channon


The DOCTYPE declaration declares the location of product-specific parts of the
Ant build file. You can change the values of these declarations to point to
other available files. This gives you an opportunity to choose what database.

Note that this syntax has nothing to do with Ant or Middlegen. This
is the standard way defined by w3c to dynamically include external
files in an XML document. Any decent XML parser will do the include
transparently. Try to open this file in Internet Explorer and see
for yourself.
-->

<!DOCTYPE project [
<!ENTITY database SYSTEM "file:./config/database/oracle.xml">
]>


<project name="Middlegen Hibernate" default="all" basedir=".">

<!-- project name="Middlegen Hibernate" default="all" basedir="." -->

<property file="${basedir}/build.properties"/>
<property name="name" value="airline"/>

<!-- This was added because we were several people (in a course) deploying to same app server>
<property environment="env"/>
<property name="unique.name" value="${name}.${env.COMPUTERNAME}"/-->

<property name="gui" value="true"/>

<property name="unique.name" value="${name}"/>

<property name="appxml.src.file" value="${basedir}/src/application.xml"/>
<property name="lib.dir" value="${basedir}/lib"/>
<property name="src.dir" value="${basedir}/src"/>
<property name="java.src.dir" value="${src.dir}/java"/>
<property name="web.src.dir" value="${src.dir}/web"/>

<property name="build.dir" value="${basedir}/build"/>
<property name="build.java.dir" value="${build.dir}/java"/>
<property name="build.gen-src.dir" value="${build.dir}/gen-src"/>
<property name="build.classes.dir" value="${build.dir}/classes"/>

&database;

<!-- define the datasource.jndi.name in case the imported ejb file doesn't -->
<property name="datasource.jndi.name" value="${name}/datasource"/>

<path id="lib.class.path">
<pathelement path="${database.driver.classpath}"/>
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
<!-- The middlegen jars -->
<!--fileset dir="${basedir}/.."-->
<fileset dir="${basedir}/middlegen-lib">
<include name="*.jar"/>
</fileset>
</path>

<target name="init">
<available property="xdoclet1.2+" classname="xdoclet.modules.hibernate.HibernateDocletTask" classpathref="lib.class.path"/>
</target>

<!-- =================================================================== -->
<!-- Fails if XDoclet 1.2.x is not on classpath -->
<!-- =================================================================== -->
<target name="fail-if-no-xdoclet-1.2" unless="xdoclet1.2+">
<fail>
You must download several jar files before you can build Middlegen.
</fail>
</target>

<!-- =================================================================== -->
<!-- Create tables -->
<!-- =================================================================== -->
<target
name="create-tables"
depends="init,fail-if-no-xdoclet-1.2,check-driver-present,panic-if-driver-not-present"
description="Create tables"
>
<echo>Creating tables using URL ${database.url}</echo>
<sql
classpath="${database.driver.classpath}"
driver="${database.driver}"
url="${database.url}"
userid="${database.userid}"
password="${database.password}"
src="${database.script.file}"
print="true"
output="result.txt"
/>
</target>
<target name="check-driver-present">
<available file="${database.driver.file}" type="file" property="driver.present"/>
</target>
<target name="panic-if-driver-not-present" unless="driver.present">
<fail>
The JDBC driver you have specified by including one of the files in ${basedir}/config/database
doesn't exist. You have to download this driver separately and put it in ${database.driver.file}
Please make sure you're using a version that is equal or superior to the one we looked for.
If you name the driver jar file differently, please update the database.driver.file property
in the ${basedir}/config/database/xxx.xml file accordingly.
</fail>
</target>

<!-- =================================================================== -->
<!-- Run Middlegen -->
<!-- =================================================================== -->
<target
name="middlegen"
description="Run Middlegen"
unless="middlegen.skip"
depends="init,fail-if-no-xdoclet-1.2,check-driver-present,panic-if-driver-not-present"
>
<mkdir dir="${build.gen-src.dir}"/>

<echo message="Class path = ${basedir}"/>
<taskdef
name="middlegen"
classname="middlegen.MiddlegenTask"
classpathref="lib.class.path"
/>

<middlegen
appname="${name}"
prefsdir="${src.dir}"
gui="${gui}"
databaseurl="${database.url}"
initialContextFactory="${java.naming.factory.initial}"
providerURL="${java.naming.provider.url}"
datasourceJNDIName="${datasource.jndi.name}"
driver="${database.driver}"
username="${database.userid}"
password="${database.password}"
schema="${database.schema}"
catalog="${database.catalog}"
>

<!--
We can specify what tables we want Data generated for.
If none are specified, Data will be generated for all tables.
Comment out the <table> elements if you want to generate for all tables.
Also note that table names are CASE SENSITIVE for certain databases,
so on e.g. Oracle you should specify table names in upper case.
-->
<table generate="true" name="EMP" pktable="EMPNO"/>
<!--table name="reservations"/-->

<!--
If you want m:n relations, they must be specified like this.
Note that tables declare in multiple locations must all have
the same value of the generate attribute.
-->
<!--many2many>
<tablea generate="true" name="persons"/>
<jointable name="reservations" generate="false"/>
<tableb generate="true" name="flights"/>
</many2many-->


<!-- Plugins - Only Hibernate Plugin has been included with this special distribution -->

<!--
If you want to generate XDoclet markup for hbm2java to include in the POJOs then
set genXDocletTags to true. Also, composite keys are generated as external classes which is
recommended. If you wish to keep them internal then set genIntergratedCompositeKeys to true.
Since r4 the ability to customise the selection of JavaTypes is now provided. The is a
recommended type mapper provided as shown. It is optional - if not provided then Middlegen
itself will select the Java mapping (as it did previously).
These settings are optional thus if they are not define here values default to false.
-->
<hibernate
destination="${build.gen-src.dir}"
package="${name}.hibernate"
genXDocletTags="false"
genIntergratedCompositeKeys="false"
javaTypeMapper="middlegen.plugins.hibernate.HibernateJavaTypeMapper"
/>

</middlegen>

<mkdir dir="${build.classes.dir}"/>
</target>

<!-- =================================================================== -->
<!-- Compile business logic (hibernate) -->
<!-- =================================================================== -->
<target name="compile-hibernate" depends="middlegen" description="Compile hibernate Business Domain Model">
<javac
srcdir="${build.gen-src.dir}"
destdir="${build.classes.dir}"
classpathref="lib.class.path"
>
<include name="**/hibernate/**/*"/>
</javac>
</target>

<!-- =================================================================== -->
<!-- Run hbm2java depends="middlegen" -->
<!-- =================================================================== -->
<target name="hbm2java" description="Generate .java from .hbm files.">
<taskdef
name="hbm2java"
classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
classpathref="lib.class.path"
/>

<hbm2java output="${build.gen-src.dir}">
<fileset dir="${build.gen-src.dir}">
<include name="**/*.hbm.xml"/>
</fileset>
</hbm2java>
</target>

<!-- =================================================================== -->
<!-- Build everything -->
<!-- =================================================================== -->
<target name="all" description="Build everything" depends="compile-hibernate"/>

<!-- =================================================================== -->
<!-- Clean everything -->
<!-- =================================================================== -->
<target name="clean" description="Clean all generated stuff">
<delete dir="${build.dir}"/>
</target>

<!-- =================================================================== -->
<!-- Brings up the hsqldb admin tool -->
<!-- =================================================================== -->
<target name="hsqldb-gui" description="Brings up the hsqldb admin tool">
<property name="database.urlparams" value="?user=${database.userid}&amp;password=${database.password}"/>
<java
classname="org.hsqldb.util.DatabaseManager"
fork="yes"
classpath="${lib.dir}/hsqldb-1.7.1.jar;${database.driver.classpath}"
failonerror="true"
>
<arg value="-url"/>
<arg value="${database.url}${database.urlparams}"/>
<arg value="-driver"/>
<arg value="${database.driver}"/>
</java>
</target>

<!-- ==================================================================== -->
<!-- Validate the generated xml mapping documents -->
<!-- ==================================================================== -->
<target name="validate">
<xmlvalidate failonerror="no" lenient="no" warn="yes">
<fileset dir="${build.gen-src.dir}/airline/hibernate" includes="*.xml" />
</xmlvalidate>
</target>

</project>


My oracle.xml looks like this
<!-- =================================================================== -->
<!-- ant properties/targets for oracle 8/9 -->
<!-- note: this is not a proper xml file (there is no root element) -->
<!-- it is intended to be imported from a *real* xml file -->
<!-- =================================================================== -->

<!-- please set your Oracle-SID according to your needs -->

<property environment="env"/>

<property name="database.script.file" value="${src.dir}/sql/${name}-oracle.sql"/>
<property name="database.driver.file" value="${lib.dir}/ojdbc14.jar"/>
<property name="database.driver.classpath" value="${database.driver.file}"/>
<property name="database.driver" value="oracle.jdbc.driver.OracleDriver"/>
<property name="database.url" value="jdbc:oracle:thin:@192.186.0.2:1521:pkemrdvp"/>
<property name="database.userid" value="scott"/>
<property name="database.password" value="tiger"/>
<property name="database.schema" value="scott"/>
<property name="database.catalog" value=""/>

<!--property name="jboss.datasource.mapping" value="Oracle7"/-->
<!--property name="jboss.datasource.mapping" value="Oracle8"/>
<property name="jboss.datasource.mapping" value="Oracle9i"/-->


===========================================

Please help me asaap.

Regards,
Shoaib Akhtar


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 08, 2004 7:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
While I experiment with the issue. You can use an earlier version of hbm2java which always builds the equals/hashcode. It might not be ideal but it should keep you going while I look at this issue.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 09, 2004 4:14 am 
Regular
Regular

Joined: Tue Mar 23, 2004 2:10 am
Posts: 51
Hi david,
In the meantime i want to tell you another interesting fact. If my schema contains less number of objects (table, procedure, etc) such as the default schema od scott Middlegen works with table tag but if schema conatins large number of objects (the one i am using has more than 800 tables) then it do not work.May be it can help you.

Regrads,
Shoaib Akhtar


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 09, 2004 4:13 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
try
export ANT_OPTS=-Xmx512M
ant middlegen

regards


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 09, 2004 9:04 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Thank you (again) snpesnpe for helping me answer the questions. Its nice to see others in the community help out.

You need to provide more memory to you JVM. The ant option above provides the jvm argument to allow the JVM to allocate a larger pool of memory.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 09, 2004 9:08 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
I make type error - always - it is snpe, no snpesnpe, bu I don't know change
name

regards


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 09, 2004 9:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
OK - Thanks snpe. Maybe Christian can change it for you. I'm not sure - you can email him and ask.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 10, 2004 12:24 am 
Regular
Regular

Joined: Tue Mar 23, 2004 2:10 am
Posts: 51
Hello,
Thanks snpe and david for your help it worked for me. But i wonder why there is no need to increase heap size when i use the whole schema (800 tables) and when i use only one table i have to increase heap size it should be improved? Is not it so.

Regards and Thanks from,
Shoaib Akhtar


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 10, 2004 10:32 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
shema size is increased for ant only, not for middlegen task
middlegen call ant more times for one table (probably)

regards


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