-->
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.  [ 20 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Hibernate Tools Reveng does not work with generated-class
PostPosted: Thu Oct 11, 2007 10:13 am 
Beginner
Beginner

Joined: Sun Sep 30, 2007 2:58 pm
Posts: 26
Hi,

I've tried to use the meta attribute "generated-class" inside the hibernate.reveng.xml but it did not work... I've tried several configurations:

Code:
<hibernate-reverse-engineering>
   <table-filter match-name="email_messages">
      <meta attribute="generated-class">EmailMessage</meta>
   </table-filter>
</hibernate-reverse-engineering>


Code:
<hibernate-reverse-engineering>
   <table-filter match-name="email_messages"/>
   <table name="email_messages" class="EmailMessage"/>
</hibernate-reverse-engineering>


Code:
<hibernate-reverse-engineering>
   <table-filter match-name="email_messages"/>
   <table name="email_messages" class="EmailMessage">
      <meta attribute="generated-class">EmailMessage</meta>
   </table>
</hibernate-reverse-engineering>


Any idea? I can not do it using hbm.xml as I'm just using POJO with annotations...

Thanks,
Leonardo


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 12, 2007 1:43 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
What db ? casing might be relevant.

How does your generate classes look like ?

How are you calling this ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 12, 2007 9:05 am 
Beginner
Beginner

Joined: Sun Sep 30, 2007 2:58 pm
Posts: 26
Database: Mysql 5
Database Driver: Mysql JDBC 5.0.7

The classname looks like the default name (camelCase): "EmailMessages".

I'm using ant task to invoke hibernate tools:

Code:
<taskdef name="hibernatetool"
        classname="org.hibernate.tool.ant.HibernateToolTask"
        classpathref="class.path"/>

<target name="hbm2java" description="hbm2java">
         <hibernatetool destdir="${src-hbmtools.dir}">
            <jdbcconfiguration configurationfile="${hbm.tools}/hibernate-mysql.cfg.xml"
                             revengfile="${hbm.tools}/hibernate.reveng.xml"
                         packagename="bizservices.test.model"
                         detectmanytomany="true"/>            
                <!-- Generate POJOs -->
            <hbm2java jdk5="true" ejb3="true"/>
         </hibernatetool>
</target>


hibernate-mysql.cfg.xml
Code:
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/dpst</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.connection.password">xxxxx</property>
        <property name="hibernate.default_schema">DPST</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
    </session-factory>
</hibernate-configuration>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 12, 2007 9:22 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you did not show me the actual generated files. please do.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 12, 2007 9:30 am 
Beginner
Beginner

Joined: Sun Sep 30, 2007 2:58 pm
Posts: 26
OK...

EmailMessages.java
Code:
package bizservices.test.model;

import bizservices.framework.model.BaseModel;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
* Model Class: EmailMessages
* @author HibernateTools3.2.0.b9 12-Oct-2007 9:24:28 AM
*/
@Entity
@Table(name="email_messages"
      ,uniqueConstraints = @UniqueConstraint(columnNames="EML_MSG_CD"))
@NamedQuery(name  = "jpql.EmailMessages.by.uk",
         query = "select o from EmailMessages o where o.emlMsgCd = :emlMsgCd")
public class EmailMessages extends BaseModel {

    @Id
    @Column(name="EML_MSG_ID", unique=true, nullable=false)     
   private int emlMsgId;

    @Column(name="EML_MSG_CD", unique=true, nullable=false, length=30)     
   private String emlMsgCd;

    @Column(name="EML_MSG_SUBJECT", nullable=false)     
   private String emlMsgSubject;

   /**
    * Default Constructor
    */
   public EmailMessages() {
   }
   /**
    * Minimum Constructor
    */
   public EmailMessages(int emlMsgId, String emlMsgCd, String emlMsgSubject) {
      this.emlMsgId = emlMsgId;
      this.emlMsgCd = emlMsgCd;
      this.emlMsgSubject = emlMsgSubject;
   }
   public int getEmlMsgId() {
      return this.emlMsgId;
   }
   public void setEmlMsgId(int emlMsgId) {
      this.emlMsgId = emlMsgId;
   }

   public String getEmlMsgCd() {
      return this.emlMsgCd;
   }
   public void setEmlMsgCd(String emlMsgCd) {
      this.emlMsgCd = emlMsgCd;
   }

   public String getEmlMsgSubject() {
      return this.emlMsgSubject;
   }
   public void setEmlMsgSubject(String emlMsgSubject) {
      this.emlMsgSubject = emlMsgSubject;
   }
}


PojoTypeDeclaration.ftl:
Code:
/**
* Model Class: ${pojo.getDeclarationName()}
* @author HibernateTools${version} ${date}
*/
<#include "Ejb3TypeDeclaration.ftl"/>
${pojo.getClassModifiers()} ${pojo.getDeclarationType()} ${pojo.getDeclarationName()} extends ${pojo.importType("bizservices.framework.model.BaseModel")} {


If you need to see more templates, let me know...

By the way, is it possible to attach some file in this forum?

Thanks again!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 16, 2007 11:09 am 
Beginner
Beginner

Joined: Sun Sep 30, 2007 2:58 pm
Posts: 26
Do you have some idea to solve this problem? or anybody?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 16, 2007 11:12 am 
Beginner
Beginner

Joined: Sun Sep 30, 2007 2:58 pm
Posts: 26
Do you have some idea to solve this problem? or anybody?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 16, 2007 11:13 am 
Beginner
Beginner

Joined: Sun Sep 30, 2007 2:58 pm
Posts: 26
Do you have some idea to solve this problem? or anybody?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 17, 2007 12:49 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
I can't see why your match shouldn't be found since the table name matches.

What is weird though is that the table names seem to be in lower case, but columns in uppercase ...not seen that before.

Have you tried using uppercase table names in the filter?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 17, 2007 8:49 am 
Beginner
Beginner

Joined: Sun Sep 30, 2007 2:58 pm
Posts: 26
If I use uppercase, no file is generated as if the table had not been found... The DDL for the table is:

Code:
CREATE TABLE email_messages (
    EML_MSG_ID        int(11) AUTO_INCREMENT NOT NULL,
    EML_MSG_CD        VARCHAR(30) NOT NULL,
    EML_MSG_SUBJECT     VARCHAR(255) NOT NULL,
    PRIMARY KEY(EML_MSG_ID)
);
ALTER TABLE email_messages
    ADD CONSTRAINT EMAIL_MESSAGES_CD_UK
   UNIQUE (EML_MSG_CD);


However, I can do:

SELECT * FROM EMAIL_MESSAGES
or
SELECT * FROM email_messages

Both work...

Thanks for helping again!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 18, 2007 1:23 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
if that is the case then the following *must* work:

Code:
<hibernate-reverse-engineering>
   <table-filter match-name="email_messages"/>
   <table name="email_messages" class="EmailMessage"/>
</hibernate-reverse-engineering>

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 18, 2007 8:36 am 
Beginner
Beginner

Joined: Sun Sep 30, 2007 2:58 pm
Posts: 26
Yeah, but unfortunetly it is not working... It generates the classname as EmailMessages... Any idea? Did you try it?

By the way, I'm using hibernate tools beta9, because I got some errors using beta10 in my eclipse (3.2)...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 24, 2007 11:21 am 
Beginner
Beginner

Joined: Sun Sep 30, 2007 2:58 pm
Posts: 26
Any ideia? May I open a jira request?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 24, 2007 4:40 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
sure,but please try with latest release first.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 09, 2008 1:51 pm 
Beginner
Beginner

Joined: Sun Sep 30, 2007 2:58 pm
Posts: 26
I tried using the latest version CR1 and didn't work. So I created a Jira request:

http://opensource.atlassian.com/projects/hibernate/browse/HBX-1031


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 20 posts ]  Go to page 1, 2  Next

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.