-->
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: Hibernate Reverse Engineering Set with Composite Keys
PostPosted: Thu Oct 02, 2014 1:27 pm 
Newbie

Joined: Thu Sep 25, 2014 5:10 pm
Posts: 2
I'm having trouble getting Hibernate to correctly reverse engineer a MySQL database into a Java Class.

I have 3 tables:
•departments (pk = dept_no)
•employees (pk = emp_no)
•dept_emp (composite pks dept_no and emp_no)

I am trying to modify the Hibernate Reverse Engineering file to force the DeptEmp Java class that is generated to link a single department to a set of employees within that department, but I keep getting the same error, even though I have declared a name attribute for the set:

Code:
org.hibernate.MappingException: Could not configure overrides from file: C:\lib\workspace\Hibernate Analysis 2\resources\hibernate.reveng.xml
Could not configure overrides from file: C:\lib\workspace\Hibernate Analysis 2\resources\hibernate.reveng.xml
org.hibernate.MappingException: Could not configure overrides from file: C:\lib\workspace\Hibernate Analysis 2\resources\hibernate.reveng.xml
Could not configure overrides from file: C:\lib\workspace\Hibernate Analysis 2\resources\hibernate.reveng.xml
org.hibernate.MappingException: invalid override definition
invalid override definition
org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 88; Attribute "name" must be declared for element type "set".
Attribute "name" must be declared for element type "set".


My Reverse Engineering File:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >

<hibernate-reverse-engineering>
    <table-filter match-catalog="employees" match-name="departments" />
    <table-filter match-catalog="employees" match-name="employees" />
    <table-filter match-catalog="employees" match-name="dept_emp" />

    <table name="dept_emp" class="com.DeptEmp">
        <set name="employeesSet" table="employees" inverse="true" lazy="true" fetch="select">
            <key>
                <column name="dept_no" ></column>
            </key>
            <one-to-many class="com.Employees"></one-to-many>
        </set>
    </table>
</hibernate-reverse-engineering>


My Hibernate Config:
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.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/employees</property>
        <property name="hibernate.connection.username">****</property>
        <property name="hibernate.connection.password">****</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.default_catalog">employees</property>
        <property name="connection.pool_size">20</property>
        <property name="current_session_context_class">thread</property>
        <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
        <property name="show_sql">true</property>
        <property name="format_sql">true</property>
        <property name="use_sql_comments">true</property>

    </session-factory>
</hibernate-configuration>


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.