Hibernate version:
2.1.6
Mapping documents:
trivial (team-player example)
Code between sessionFactory.openSession() and session.close():
I can't get that far yet.
Full stack trace of any exception that occurs:
java.lang.NoClassDefFoundError: net/sf/hibernate/tool/hbm2java/CodeGenerator
Name and version of the database you are using:
MySQL 4.0.21-nt
The generated SQL (show_sql=true):
I can't get that far yet.
Debug level Hibernate log excerpt:
I can't get that far yet.
Good header, bTW. I am building a java project (in Eclipse 3) that uses mySQL for the back end. This is simple -- not even an enterprise app. The JDBC connections work fine, but before I get too far into the project I wanna make sure I have all the utils up and running that I would need.
Enter Hibernate. Looks like a great tool. I can't get it to work.
I made 2 mapping files. Here they are:
Code:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="example.Team" table="teams">
<id name="id" column="team_id" type="long" unsaved-value="null">
<generator class="hilo"/>
</id>
<property name="name" column="team_name" type="string"
length="15" not-null="true"/>
<property name="city" column="city" type="string" length="15" not-null="true"/>
<set name="players" cascade="all" inverse="true" lazy="true">
<key column="team_id"/>
<one-to-many class="example.Player"/>
</set>
</class>
</hibernate-mapping>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="example.Player" table="players">
<id name="id" column="player_id" type="long" unsaved-value="null">
<generator class="hilo"/>
</id>
<property name="firstName" column="first_name" type="string" length="12" not-null="true"/>
<property name="lastName" column="last_name" type="string" length="15" not-null="true"/>
<property name="draftDate" column="draft_date" type="date"/>
<property name="annualSalary" column="salary" type="float"/>
<property name="jerseyNumber" column="jersey_number" type="integer" length="2" not-null="true"/>
<many-to-one name="team" class="example.Team" column="team_id"/>
</class>
</hibernate-mapping>
</text>
Then I started to run schemaexport. The error messages I got made me realize I needed the java stubs to be generated first, so I tried to run the code generator. I made a batch file similar to the supplied schemaexport.bat and got the NoClassDefFoundError mentioned above. So, I started looking in the binary distribution I had downloaded (hibernate-2.1.6.zip -- 17,497,476 bytes) trying to find the CodeGenerator class. It's nowhere to be found. Some other forum I googled up had a message about an ext package. I don't see anything like that here. I also looked in all the jar files that came with the distribution to see if I could find any hint of it there, or in the src tree. Nope. Where is it?