facebook

Generated POJOs feature: problem, or misunderstanding?

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MyEclipse Archived
  2.  > 
  3. Bugs
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #260647 Reply

    lallgood
    Member

    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:

    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. = )

    #260654

    lallgood
    Member

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

    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.

    #260772

    Haris Peco
    Member

    lallgood ,

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

    Regards,

    #260775

    lallgood
    Member

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

    Here Honey.hbm.xml is:

    
     <?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:

    
     <?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.

    #260777

    Haris Peco
    Member

    lallgood ,

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

    Regards,

    Attachments:
    You must be logged in to view attached files.
Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Generated POJOs feature: problem, or misunderstanding?

You must be logged in to post in the forum log in