facebook

Bug in 4.0M3 – generate Hibernate mapping

💡
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 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #235592 Reply

    Some of the generated .hbm.xml files does not validate:

    
    The content of element type "class" must match "(meta*, subselect?, cache?, synchronize*, comment?, (id|composite-id), discriminator?, natural-id?, (version|timestamp)?, (property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array|query-list)*, ((join*,subclass*)|joined-subclass*|union-subclass*), loader?, sql-insert?, sql-update?, sql-delete?, filter*)".
    
    BagsVqueue.hbm.xml    Proj/java/src/forit/hibernate    line 24    24. august 2005 13:00:00
    

    generated .hbm.xml source 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" >
    
    <!-- DO NOT EDIT: This is a generated file that is synchronized -->
    <!-- by MyEclipse Hibernate tool integration.                   -->
    <!-- Created Mon Aug 15 11:04:03 CEST 2005                         -->
    <hibernate-mapping package="forit.hibernate">
    
        <class name="BagsVqueue" table="Bags_VQueue">
     
            <property name="unitid" column="UnitId" type="integer"  not-null="true" />
            <property name="bagno" column="BagNo" type="string" />
            <property name="orderno" column="OrderNo" type="string" />
            <property name="serialno" column="SerialNo" type="string" />
            <property name="articleno" column="ArticleNo" type="string" />
            <property name="actualweight" column="ActualWeight" type="double" />
            <property name="lineid" column="LineId" type="integer" />
            <property name="packdate" column="PackDate" type="timestamp" />
            <property name="expiredate" column="ExpireDate" type="timestamp" />
            <property name="isready" column="IsReady" type="short" />
            <property name="bagseq" column="BagSeq" type="short" />
        </class>
        
    </hibernate-mapping>
    
    
    #235621

    Riyad Kalla
    Member

    you are missing a PK field for the table you mapped, so no identiy tag is getting generated, that is the problem. You must have an identity field.

    #235628

    @support-rkalla wrote:

    you are missing a PK field for the table you mapped, so no identiy tag is getting generated, that is the problem. You must have an identity field.

    In this case, the mapped ‘table’ was actually a view, and have no explicit primary key.

    #235630

    Riyad Kalla
    Member

    Hibernate requires a identity field for the table, if there is no way to uniquely identify the table then that is likely what confused our mapper and won’t work with hibernate. If the identity is a composite key then you may try entering it manually. We will eventually address these more complex mappings and for the time being appologize for the inconvenience.

    #235673

    @support-rkalla wrote:

    Hibernate requires a identity field for the table, if there is no way to uniquely identify the table then that is likely what confused our mapper and won’t work with hibernate. If the identity is a composite key then you may try entering it manually. We will eventually address these more complex mappings and for the time being appologize for the inconvenience.

    Yes, but for views you often/usually does not have an explicit primary key value, but in general views usually are created in a way that at least each record is unique.

    In a tool like e.g. MiddleGen, this is solved by making all columns part of a composite key when generating mappings for a view. This is an OK way of generating a mapping for a view in most cases.

    Of course it would be even better to let you manually select key/composite key columns in the tool, but then it is absolutely required that the tool remembers this decision, so that a re-generation does not destroy your previous selection!

    So, as I see it there are two solutions:
    1. Let you use the tool (ME) to define PK/composite PK, and re-use this info when regenerating the mappings.
    2. quick fix: Let the tool make all columns part of a composite PK when generating mappings for a view.

    I would say that solution # 2 is easy enough to implement that it should be included in the 4.0 release, and that it would be great to have solution #1 added at a later time.

    footnote:
    In my last project (using MiddleGen to generate the mappings) we re-generated the hibernate mappings 100+ times during development, and our database contained 120 tables and 80 views. If we had to manually fix the generated view mappings after each generation, I would have had to manually fix 8000 files for something that should be very easy to include in the tool……

    #235683

    Riyad Kalla
    Member

    keb,
    We fully understand the limitation of the tool given the current setting, that is why we invested the time to develop our visual mapper that was suppose to be in 4.0 but got shelved until a later version due to user demand for Hibernate 3 support instead. The idea of #1 is what the visual mapper will allow and handle. We hope to get it into 5.0.

    #235743

    @support-rkalla wrote:

    keb,
    We fully understand the limitation of the tool given the current setting, that is why we invested the time to develop our visual mapper that was suppose to be in 4.0 but got shelved until a later version due to user demand for Hibernate 3 support instead. The idea of #1 is what the visual mapper will allow and handle. We hope to get it into 5.0.

    OK, that sounds good, but could you please consdier ‘quickfixing’ in 4.0(x) so that the generation of hibernate mappings from views consider all fields part of a composite PK?
    That way the tool would also be quite usable as is.

    #235770

    Riyad Kalla
    Member

    The tool honors the PK/FK metadata it receives from the JDBC driver, does your view table have any PK set or is it just a table with a ton of columns?

    #235847

    @support-rkalla wrote:

    The tool honors the PK/FK metadata it receives from the JDBC driver, does your view table have any PK set or is it just a table with a ton of columns?

    It is in some cases just a ‘ton of columns’ 🙂
    The thing is that quite a few of the views does not have any specific PK, but they return unique rows as results when we query them.

    So what you say, is that if I define all columns of the view as being part of one really heavy (weighing a ton or somtehing:-) PK,
    I would actually solve this problem and get generated a functional hibernate mapping for the view?
    – I’ll try that first thing in the morning…..

    #235849

    Riyad Kalla
    Member

    So what you say, is that if I define all columns of the view as being part of one really heavy (weighing a ton or somtehing:-) PK,
    I would actually solve this problem and get generated a functional hibernate mapping for the view?

    Correct, our tool will see all the elements of your PK and generate one huge composite PK for you. If it doesn’t, I’d consider that a bug.

Viewing 10 posts - 1 through 10 (of 10 total)
Reply To: Bug in 4.0M3 – generate Hibernate mapping

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