-->
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.  [ 1 post ] 
Author Message
 Post subject: Tools problem with Annotations and hbm2ddl
PostPosted: Thu Jan 25, 2007 3:46 pm 
Newbie

Joined: Thu Jan 25, 2007 3:18 pm
Posts: 1
Hi,

I've searched the forums and documentation and the Bauer book, and have just downloaded the source and am beginning to pour through that for answers.

But in case someone else knows what's going on (or can at least point me in the right direction)...

I am writing a utility that will allow its end-users to change the database schema (and subsequently the beans too). Basically, this is to allow for user-defined fields. We can't allow the end-user to use the SQL Server Enterprise Manager or anything else because we need to keep db independence.

I'm testing it out, and everything goes ok until I try to run hbm2ddl via an ant task. I don't understand why it's complaining that "No identifier specified for entity: com.hti.ez.sah.generated.TestBean" when I can use code that is generated by the reverse engineering with annotations turned on just fine.

Here's the code I'm trying to compile:

Code:
package com.hti.ez.sah.generated;


/**
* <pre>
* This is generated source code based upon entries made in the
* Template Builder. <b><i>Do not edit this file. Changes will
* be lost the next time it is generated!</i></b>
*
*Generation stats:
*   Date:            Thu Jan 25 12:58:02 CST 2007
*   JDK:            1.5.0_08(Sun Microsystems Inc.)
*   OS:               Windows XP(x86)
*   Beanmaker Revision:   $Revision: 1.4 $
*   Classpath:         C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-antlr.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-apache-bcel.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-apache-bsf.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-apache-log4j.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-apache-oro.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-apache-regexp.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-apache-resolver.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-commons-logging.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-commons-net.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-icontract.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-jai.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-javamail.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-jdepend.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-jmf.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-jsch.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-junit.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-launcher.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-netrexx.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-nodeps.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-starteam.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-stylebook.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-swing.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-trax.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-vaj.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-weblogic.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-xalan1.jar;C:\ECLIPSE-3.2.1\plugins\org.apache.ant_1.6.5\lib\ant-xslp.jar;C:\ECLIPSE-3.2.1\plugins\net.sf.fjep.fatjar_0.0.24\fatjar.jar;C:\ECLIPSE-3.2.1\configuration\org.eclipse.osgi\bundles\10\1\.cp\lib\remoteAnt.jar;C:\Program Files\Java\jdk1.5.0\lib\tools.jar;C:\ECLIPSE-3.2.1\plugins\org.eclipse.swt.win32.win32.x86_3.2.1.v3235.jar
*</pre>
*
* @author jpartyka (This is the user who ran the code generation utility.)
*/

import javax.persistence.CascadeType;
import javax.persistence.Column;
import org.hibernate.annotations.Entity;
import org.hibernate.annotations.AccessType;

//import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.persistence.GeneratedValue;
import javax.persistence.SecondaryTable;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;


@Entity @AccessType("METHOD")
@Table(name = "TestBean")
// use an inheritance strategy of one table per class/normalized subclasses.
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)

public class TestBean implements com.hightower.drools.beans.data.RuleObject {

   /**
    * The name of the blind.
    */


private java.lang.String BlindName = null;
   /**
    * Maximum Width.
    */


private java.math.BigDecimal MaxWidth = null;
   /**
    * Maximum Height.
    */


private java.math.BigDecimal MaxHeight = null;
   /**
    * The type of blind.
    */


private java.lang.String BlindType = "";
   /**
    * Maximum Area.
    */


private java.math.BigDecimal MaxArea = null;
   /**
    * A description of the blind.
    */


private java.lang.String BlindDescription = "";


   private Long theIdentity = null;

   @Id @GeneratedValue   
   @Column(name = "theIdentity", unique = true, nullable = false, insertable = true, updatable = true)   
   public final Long getTheIdentity() {
      return this.theIdentity;
   }

      /**
       * Sets the BlindName field.
       * @param BlindName A valid java.lang.String value.
       */
      public final void setBlindName(final java.lang.String local_BlindName) {
         this.BlindName = local_BlindName;
      }
      /**
       * Retrieve the value of field BlindName.
       * @return An object of java.lang.String
       *   containing the value of BlindName.
       */

      @Column(table = "TestBean",
         name = "BlindName",
         nullable = false,
         insertable = true,
         length = 64,
         updatable = true)

      public final java.lang.String getBlindName() {
         return this.BlindName;
      }
      /**
       * Sets the MaxWidth field.
       * @param MaxWidth A valid java.math.BigDecimal value.
       */
      public final void setMaxWidth(final java.math.BigDecimal local_MaxWidth) {
         this.MaxWidth = local_MaxWidth;
      }
      /**
       * Retrieve the value of field MaxWidth.
       * @return An object of java.math.BigDecimal
       *   containing the value of MaxWidth.
       */

      @Column(table = "TestBean",
         name = "MaxWidth",
         nullable = false,
         insertable = true,
         updatable = true)

      public final java.math.BigDecimal getMaxWidth() {
         return this.MaxWidth;
      }
      /**
       * Sets the MaxHeight field.
       * @param MaxHeight A valid java.math.BigDecimal value.
       */
      public final void setMaxHeight(final java.math.BigDecimal local_MaxHeight) {
         this.MaxHeight = local_MaxHeight;
      }
      /**
       * Retrieve the value of field MaxHeight.
       * @return An object of java.math.BigDecimal
       *   containing the value of MaxHeight.
       */

      @Column(table = "TestBean",
         name = "MaxHeight",
         nullable = false,
         insertable = true,
         updatable = true)

      public final java.math.BigDecimal getMaxHeight() {
         return this.MaxHeight;
      }
      /**
       * Sets the BlindType field.
       * @param BlindType A valid java.lang.String value.
       */
      public final void setBlindType(final java.lang.String local_BlindType) {
         this.BlindType = local_BlindType;
      }
      /**
       * Retrieve the value of field BlindType.
       * @return An object of java.lang.String
       *   containing the value of BlindType.
       */

      @Column(table = "TestBean",
         name = "BlindType",
         nullable = false,
         insertable = true,
         length = 128,
         updatable = true)

      public final java.lang.String getBlindType() {
         return this.BlindType;
      }
      /**
       * Retrieve the value of field MaxArea.
       * @return An object of java.math.BigDecimal
       *   containing the value of MaxArea.
       */
      @org.hibernate.annotations.Formula("MaxWidth * MaxHeight")      

      public final java.math.BigDecimal getMaxArea() {
         return this.MaxArea;
      }
      /**
       * Sets the BlindDescription field.
       * @param BlindDescription A valid java.lang.String value.
       */
      public final void setBlindDescription(final java.lang.String local_BlindDescription) {
         this.BlindDescription = local_BlindDescription;
      }
      /**
       * Retrieve the value of field BlindDescription.
       * @return An object of java.lang.String
       *   containing the value of BlindDescription.
       */

      @Column(table = "TestBean",
         name = "BlindDescription",
         nullable = true,
         insertable = true,
         length = 1024,
         updatable = true)

      public final java.lang.String getBlindDescription() {
         return this.BlindDescription;
      }
}



Here's the hibernate.cfg.xml:
Code:
<?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.bytecode.use_reflection_optimizer">false</property>
        <property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:jtds:sqlserver://10.0.20.127/EZ;user=sa;password=htilms</property>
        <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
        <mapping class="com.hti.ez.sah.generated.TestBean" />
        <mapping class="com.hti.ez.sah.generated.TestBeanChild" />
    </session-factory>
</hibernate-configuration>


ant task from build.xml:
Code:
<?xml version="1.0"?>
<project name="ShopAtHome" default="hbm2ddl">

    <!-- Global properties for this build -->
    <property name="src.java.dir"           location="src/java"/>
    <property name="src.etc.dir"            location="src/etc"/>
    <property name="src.conf.dir"           location="src/etc/conf"/>
    <property name="lib.dir"                location="lib"/>
    <property name="build.dir"              location="generated/build"/>
    <property name="build.classes.dir"      location="${build.dir}/classes"/>
   <property name="generatedsrc"         location="generated/src"/>
    <property name="database.dir"           location="${build.dir}/database"/>
   <property name="proj.shortname"         location="SAH"/>
   <property name="jar.location"         location="${build.dir}/dist"/>
   
    <!-- Classpath declaration -->
    <path id="project.classpath">
        <fileset dir="${lib.dir}">
            <include name="**/*.jar"/>
            <include name="**/*.zip"/>
        </fileset>
    </path>

    <path id="hightower.classpath">
       <pathelement path="bin" />
       <path refid="project.classpath" />
    </path>
   
   <path id="build.classpath">
      <pathelement path="bin" />
        <fileset dir="${lib.dir}">
            <include name="**/*.jar"/>
            <include name="**/*.zip"/>
        </fileset>
   </path>
   
   <path id="hbm2ddl.classpath">
      <path location="${build.classes.dir}" />
        <fileset dir="${lib.dir}">
            <include name="**/*.jar"/>
            <include name="**/*.zip"/>
        </fileset>      
   </path>
       
    <!-- Useful shortcuts -->
    <patternset id="meta.files">
        <include name="**/*.xml"/>
        <include name="**/*.properties"/>
        <include name="**/*.dtd"/>
        <include name="**/*.sql"/>
    </patternset>   
   
    <taskdef name="hibernatetool"
             classname="org.hibernate.tool.ant.HibernateToolTask"
             classpathref="project.classpath"/>

   <taskdef name="ExportHibernate"
          classname="com.hightower.drools.beans.hibernate.HibernateExportTask"
          classpathref="hightower.classpath" />
   
   <target name="clean" description="remove intermediate files">
        <delete dir="classes"/>
    </target>
   <target name="exportCode"
      description="Export the data information into java code.">
      <copy todir="${build.classes.dir}">
         <fileset dir="bin" />
      </copy>
      <ExportHibernate
         packageName="com.hti.ez.sah.generated"
         templateName="bin\resources\velocity\bean_template.vm"
         configTemplateName="bin\resources\velocity\hibernate.cfg.vm"
         templateDestination="${build.classes.dir}\hibernate.cfg.xml"
         desinationDir="${generatedsrc}"   
      />
   </target>
    <target name="compile" depends="exportCode" description="Compile the Java source code">
       <mkdir dir="${build.classes.dir}"/>
       <javac destdir="${build.classes.dir}" classpathref="build.classpath" debug="${javac.debug}" deprecation="${javac.deprecation}" nowarn="on">
            <src path="${generatedsrc}" />
        </javac>
            <!--
       <jar destfile="${lib.dir}/EZ.jar" basedir="${build.classes.dir}"  />
       -->
   </target>
    <target name="hbm2ddl" depends="compile"
     description="Create DDL files from the java source code.">
        <mkdir dir="${build.dir}/ddl"/>   
       <hibernatetool destdir="${build.dir}/ddl">
          <classpath>
             <path refid="hbm2ddl.classpath" />
          </classpath>
            <annotationconfiguration configurationfile="${build.classes.dir}/hibernate.cfg.xml"/>
            <hbm2ddl
                drop="true"
                create="true"
                export="false"
                outputfilename="sql.ddl"
                delimiter=";"
                format="true"
               haltonerror="true" />
        </hibernatetool> 
    </target>
</project>


and finally, here's the error from ant:
Code:
hbm2ddl:
[hibernatetool] Executing Hibernate Tool with a Hibernate Annotation/EJB3 Configuration
[hibernatetool] 1. task: hbm2ddl (Generates database schema)
[hibernatetool] 12:58:30,062  INFO Version:15 - Hibernate Annotations 3.2.1.GA
[hibernatetool] 12:58:30,109  INFO Environment:500 - Hibernate 3.2.1
[hibernatetool] 12:58:30,124  INFO Environment:533 - hibernate.properties not found
[hibernatetool] 12:58:30,140  INFO Environment:667 - Bytecode provider name : cglib
[hibernatetool] 12:58:30,156  INFO Environment:584 - using JDK 1.4 java.sql.Timestamp handling
[hibernatetool] 12:58:30,468  INFO Configuration:1457 - configuring from file: hibernate.cfg.xml
[hibernatetool] 12:58:30,703  INFO Configuration:1538 - Configured SessionFactory: null
[hibernatetool] 12:58:30,906  INFO AnnotationBinder:388 - Binding entity from annotated class: com.hti.ez.sah.generated.TestBean
[hibernatetool] 12:58:31,078  INFO EntityBinder:378 - Bind entity com.hti.ez.sah.generated.TestBean on table TestBean
[hibernatetool] An exception occurred while running exporter #2:hbm2ddl (Generates database schema)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.AnnotationException: No identifier specified for entity: com.hti.ez.sah.generated.TestBean

BUILD FAILED
C:\ClientProjects\EZ\ShopAtHome\Eclipse\Actual Project\Shop At Home\exportdatabases.xml:89: org.hibernate.AnnotationException: No identifier specified for entity: com.hti.ez.sah.generated.TestBean
   at org.hibernate.tool.ant.HibernateToolTask.reportException(HibernateToolTask.java:211)
   at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:174)
   at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
   at org.apache.tools.ant.Task.perform(Task.java:364)
   at org.apache.tools.ant.Target.execute(Target.java:341)
   at org.apache.tools.ant.Target.performTasks(Target.java:369)
   at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
   at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
   at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
   at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
   at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
   at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
   at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
Caused by: org.hibernate.AnnotationException: No identifier specified for entity: com.hti.ez.sah.generated.TestBean
   at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:627)
   at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:452)
   at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:268)
   at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1112)
   at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:56)
   at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:287)
   at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45)
   at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:171)
   ... 11 more
--- Nested Exception ---
org.hibernate.AnnotationException: No identifier specified for entity: com.hti.ez.sah.generated.TestBean
   at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:627)
   at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:452)
   at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:268)
   at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1112)
   at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:56)
   at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:287)
   at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45)
   at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:171)
   at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
   at org.apache.tools.ant.Task.perform(Task.java:364)
   at org.apache.tools.ant.Target.execute(Target.java:341)
   at org.apache.tools.ant.Target.performTasks(Target.java:369)
   at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
   at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
   at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
   at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
   at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
   at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
   at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)

Total time: 1 minute 17 seconds
[/code]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.