-->
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.  [ 2 posts ] 
Author Message
 Post subject: How to generate POJOs from hbm.xml file
PostPosted: Tue Nov 06, 2007 12:05 pm 
Beginner
Beginner

Joined: Tue Oct 30, 2007 7:57 am
Posts: 47
I am trying to generate a POJO class from a hbm.xml file, using Code Generation Dialog (I am completely new to that). Something goes wrong, because I get and error telling that cars.Option class can not be found. That's normal, it can't find the class I am trying to generate. Can anybody explain to me how to do that?.

The mapping file cars/Option.xml:

Code:
<hibernate-mapping package="cars">
   <class name="Option" table="OPTIONS">
      <id name="id" column="OPTION_ID">
         <generator class="native" />
      </id>   
      <property name="optionName" type="string" column="OPTION_NAME" unique="true" not-null="true" />   
   </class>   
</hibernate-mapping>


hibernate.cfg.xml

Code:
<hibernate-configuration>

    <session-factory>

        <!-- Database connection settings -->
        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="connection.url">jdbc:mysql://localhost:3306/cars</property>
      <property name="connection.username">root</property>
        <property name="connection.password">password</property>

        <!-- JDBC connection pool (use the built-in) -->
        <property name="connection.pool_size">1</property>

        <!-- SQL dialect -->
        <property name="dialect">org.hibernate.dialect.MySQLDialect</property>

        <!-- Enable Hibernate's automatic session context management -->
        <property name="current_session_context_class">thread</property>

        <!-- Disable the second-level cache  -->
        <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

        <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">true</property>

        <mapping resource="cars/Option.hbm.xml"/>               

    </session-factory>

</hibernate-configuration>


Option chosen in Code Generation Dialog:

Console Configuration: hiber
Output Directory: \hiber\generated
Use Java 5 Syntax
Domain Code Exporter

The error is "java.lang.ClassNotFoundException cars.Option"


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 06, 2007 12:19 pm 
Beginner
Beginner

Joined: Tue Oct 30, 2007 7:57 am
Posts: 47
Already solved I just needed to add type to id

Code:
      <id name="id" column="OPTION_ID" type="integer">
         <generator class="native" />
      </id>


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