You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Tim Holloway <ti...@mousetech.com> on 2006/11/10 13:19:31 UTC

Mapping

1. The reverse mapping tool creates an orm.xml but not annotations on 
generated Java code. Any plans on this?

2. I fed an orm.xml to Hibernate 3. It works, but if Hibernate is clever 
enough to automatically translate between camelCase Java names and 
underscore-punctuated database names, it's beyond my limited skill. I 
had to manually insert name elements into the orm.xml for complex table 
and column definitions to make it function. It's good that openjpa is 
smarter than that, but on the whole, I think I'd prefer the more 
complete orm definition - or at least an option for it. For one thing, 
I'm not sure what the implications are when people start meddling with 
the generated items and define a situation where there's no simple 
algorithmic conversion between Java name and the database name.

  Tim Holloway


Re: Mapping

Posted by Abe White <aw...@bea.com>.
>>> 1. The reverse mapping tool creates an orm.xml but not  
>>> annotations on generated Java code. Any plans on this?
>>>
>>> 2. I fed an orm.xml to Hibernate 3. It works, but if Hibernate is  
>>> clever enough to automatically translate between camelCase Java  
>>> names and underscore-punctuated database names, it's beyond my  
>>> limited skill. I had to manually insert name elements into the  
>>> orm.xml for complex table and column definitions to make it  
>>> function. It's good that openjpa is smarter than that, but on the  
>>> whole, I think I'd prefer the more complete orm definition - or  
>>> at least an option for it. For one thing, I'm not sure what the  
>>> implications are when people start meddling with the generated  
>>> items and define a situation where there's no simple algorithmic  
>>> conversion between Java name and the database name.

Thanks for pointing this out.  It should be fixed as of revision  
475026.  The orm.xml generated by the reverse mapping tool will now  
have column names, etc.
_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

Re: Mapping

Posted by Tim Holloway <ti...@mousetech.com>.
Abe White wrote:
>> 1. The reverse mapping tool creates an orm.xml but not annotations on 
>> generated Java code. Any plans on this?
>>
>> 2. I fed an orm.xml to Hibernate 3. It works, but if Hibernate is 
>> clever enough to automatically translate between camelCase Java names 
>> and underscore-punctuated database names, it's beyond my limited 
>> skill. I had to manually insert name elements into the orm.xml for 
>> complex table and column definitions to make it function. It's good 
>> that openjpa is smarter than that, but on the whole, I think I'd 
>> prefer the more complete orm definition - or at least an option for 
>> it. For one thing, I'm not sure what the implications are when people 
>> start meddling with the generated items and define a situation where 
>> there's no simple algorithmic conversion between Java name and the 
>> database name.
>
> Are you saying that the orm.xml generated by the reverse mapping tool 
> did not have the table and column names set, wherever those names 
> differed from the JPA default for the generated class/field name?  
> Could you post an example class and the generated orm.xml?
> _______________________________________________________________________
> Notice:  This email message, together with any attachments, may contain
> information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
> entities,  that may be confidential,  proprietary,  copyrighted  and/or
> legally privileged, and is intended solely for the use of the individual
> or entity named in this message. If you are not the intended recipient,
> and have received this message in error, please immediately return this
> by email and then delete it.
Here's the original, straight from the reverse mapping tool:

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm 
orm_1_0.xsd" version="1.0">
    <package>
        com.mousetech.persist
    </package>
    <access>
        PROPERTY
    </access>
    <entity class="BusStops" metadata-complete="true">
        <attributes>
            <id name="stopId"/>
            <basic name="description"/>
            <basic name="elevation"/>
            <basic name="inbound"/>
            <basic name="latitude"/>
            <basic name="longitude"/>
            <basic name="sheltered"/>
            <basic name="street1Block"/>
            <basic name="street1Name"/>
            <basic name="street1Qualifier"/>
            <basic name="street1Type"/>
            <basic name="street2Block"/>
            <basic name="street2Name"/>
            <basic name="street2Qualifier"/>
            <basic name="street2Type"/>
            <one-to-many name="routeStops" mapped-by="busStops">
                <cascade>
                    <cascade-merge/>
                </cascade>
            </one-to-many>
            <one-to-many name="tripStops" mapped-by="busStops">
                <cascade>
                    <cascade-merge/>
                </cascade>
            </one-to-many>
        </attributes>
    </entity>

Here's what I had to do to make it work. I temporarily removed the 
one-to-many references to simplify getting onlone:

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm 
orm_1_0.xsd" version="1.0">
    <package>
        com.mousetech.persist
    </package>
    <access>
        PROPERTY
    </access>
    <entity class="BusStops" metadata-complete="true">
        <table name="bus_stops"/>
        <sequence-generator name="busStopSeq"
             sequence-name="SEQ_BUS_STOPS"/>
        <attributes>
            <id name="stopId">
                <column name="stop_id"/>
                <generated-value strategy="SEQUENCE"
                    generator="busStopSeq"/>
            </id>
            <basic name="description"/>
            <basic name="elevation"/>
            <basic name="inbound"/>
            <basic name="latitude"/>
            <basic name="longitude"/>
            <basic name="sheltered"/>
            <basic name="street1Block">
                <column name="street1_block"/>           
            </basic>
            <basic name="street1Name">
                <column name="street1_name"/>           
            </basic>
            <basic name="street1Qualifier">
                <column name="street1_qualifier"/>           
            </basic>
            <basic name="street1Type">
                <column name="street1_type"/>                       
            </basic>
            <basic name="street2Block">
                <column name="street2_block"/>                       
            </basic>
            <basic name="street2Name">
                            <column name="street2_name"/>           
            </basic>
            <basic name="street2Qualifier">
                <column name="street2_qualifier"/>           
            </basic>
            <basic name="street2Type">
                <column name="street2_type"/>           
            </basic>

        </attributes>
    </entity>

Re: Mapping

Posted by Abe White <aw...@bea.com>.
> 1. The reverse mapping tool creates an orm.xml but not annotations  
> on generated Java code. Any plans on this?
>
> 2. I fed an orm.xml to Hibernate 3. It works, but if Hibernate is  
> clever enough to automatically translate between camelCase Java  
> names and underscore-punctuated database names, it's beyond my  
> limited skill. I had to manually insert name elements into the  
> orm.xml for complex table and column definitions to make it  
> function. It's good that openjpa is smarter than that, but on the  
> whole, I think I'd prefer the more complete orm definition - or at  
> least an option for it. For one thing, I'm not sure what the  
> implications are when people start meddling with the generated  
> items and define a situation where there's no simple algorithmic  
> conversion between Java name and the database name.

Are you saying that the orm.xml generated by the reverse mapping tool  
did not have the table and column names set, wherever those names  
differed from the JPA default for the generated class/field name?   
Could you post an example class and the generated orm.xml?
_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.