Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
lallgood
Post subject: Generated POJOs feature: problem, or misunderstanding?  PostPosted: Oct 18, 2006 - 09:13 PM



Joined: Oct 16, 2006
Posts: 3

Hello,

I'm using MyEclipse 5.0GA with Eclipse 3.2.1. I'm not a seasoned vet when it comes to Hibernate or MyEclipse. I am just learning and evaluating the software for future use in the not so distant future.

It was my understanding that MyEclipse was a way of working with Hibernate in an easier fashion. It was also my understanding that the two together were able to generate base classes (in Java, ofcourse) and tables (in the Database), and that it would also update both sides as you modified the XML file.

So, with that little bit stated and as the subject suggests.. I'm having a problem with the Generated POJOs feature of MyEclipse. This feature seems relatively new, and I can't seem to find much about it on Google except that it exists. In my project, I've setup my hibernate.cfg.xml, I've imported Hibernate support using the MyEclipse menu, and I've setup a Honey.hbm.xml file based on a Hibernate/MyEclipse tutorial I found.

When I right click on the Honey.hbm.xml file and select MyEclipse -> Generate POJOs, I kept the name it chose, and removed the option for creating an abstract class just for simplicity. After pressing "Next," there's a smile for a second, and then I realize the generated class has an error. Here's the class signature it generated:

Code:
public class Honey extends Honey implements java.io.Serializable {


An obvious problem for Java, but as a collegue pointed out, it may not be a bug. I'd be glad to provide any source one would need to understand this further. I was just holding off on that so as to not post a ridiculously overwhelming amount of text. = )

So, the question: Is that a glitch or is it intentional whereas the "extends <class>" is being generated from a problem in one of my XML files? Side note: if I remove the "extends Honey," the code works fine. AND this "error" occurs whether I generate the Abstract class and this one, or if I just create the base class.

Any help would be appreciate. Till then, take care. = )
 
 View user's profile Send private message  
Reply with quote Back to top
lallgood
Post subject:   PostPosted: Oct 18, 2006 - 10:30 PM



Joined: Oct 16, 2006
Posts: 3

After coming back and experimenting a little further, I believe I've discovered the signature creation is basically...

Code:
public class <TableName> extends <SpecifiedBasePersistantClass>


Basically, I realize, now, that this isn't a bug, but I'm confused why it would want to extend a class in this way.

Does anyone know of any documentation on this feature?

Thanks.
 
 View user's profile Send private message  
Reply with quote Back to top
support-snpe
Post subject:   PostPosted: Oct 20, 2006 - 10:50 PM
Moderator
Moderator


Joined: Feb 03, 2006
Posts: 1117

lallgood ,

It is strange.Please send your hibernate.cfg.xml and your hbm.xml, if it is possible.

Regards,

_________________
Peco
MyEclipse Support
Please do us a big favor and remember to vote for MyEclipse at the JDJ Reader's Choice Awards.
We really appreciate it!
 
 View user's profile Send private message  
Reply with quote Back to top
lallgood
Post subject:   PostPosted: Oct 20, 2006 - 11:19 PM



Joined: Oct 16, 2006
Posts: 3

Please bare in mind that the name is from a tutorial. = )

Here Honey.hbm.xml is:

Code:

 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
   <class name="de.laliluna.example.Honey" table="honey">
      <id name="id" column="id" type="java.lang.Integer">
         <generator class="increment" />
      </id>
      <property name="name" column="name" type="java.lang.String" />
      <property name="taste" column="taste" type="java.lang.String" />
      <property name="color" column="color" type="java.lang.String" />
      <property name="texture" column="texture" type="java.lang.String" />
   </class>
</hibernate-mapping>


And here is my 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="connection.url">jdbc:mysql://ftcstation3/firsthibernate</property>
   <property name="connection.username">Lucas</property>
   <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
   <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
   <property name="connection.password">urmoma</property>
 <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
    <!--  thread is the short name for
      org.hibernate.context.ThreadLocalSessionContext
      and let Hibernate bind the session automatically to the thread
    -->
    <property name="current_session_context_class">thread</property>
    <!-- this will show us all sql statements -->
<!--    <property name="hibernate.show_sql">false</property>-->
   
   <!--  Adjust the database schema on startup -->
   <property name="hbm2ddl.auto">update</property>
   
   <!-- mapping files -->
   <mapping resource="de/laliluna/example/Honey.hbm.xml" />

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


Thanks.
 
 View user's profile Send private message  
Reply with quote Back to top
support-snpe
Post subject:   PostPosted: Oct 20, 2006 - 11:55 PM
Moderator
Moderator


Joined: Feb 03, 2006
Posts: 1117

lallgood ,

I can't reproduce your case.Have you deselect templates and empty in Base class (see screenshoot)


Regards,

_________________
Peco
MyEclipse Support
Please do us a big favor and remember to vote for MyEclipse at the JDJ Reader's Choice Awards.
We really appreciate it!
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits