-->
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.  [ 11 posts ] 
Author Message
 Post subject: primary key override stopped working
PostPosted: Thu Mar 30, 2006 5:12 pm 
Newbie

Joined: Thu Mar 30, 2006 3:48 pm
Posts: 7
Hibernate version: 3.1.0 beta 4

Name and version of the database you are using: Microsoft SQL Server 2000

I have the following entry in my reverse engineering file:

Code:
<type-mapping>
  <sql-type jdbc-type="NUMERIC" precision="15" hibernate-type="java.math.BigDecimal" />
  <sql-type jdbc-type="VARCHAR" hibernate-type="string" />
  <sql-type jdbc-type="FLOAT" hibernate-type="java.lang.Float" />
  <sql-type jdbc-type="INTEGER" hibernate-type="java.lang.Integer" />
  <sql-type jdbc-type="DECIMAL" hibernate-type="java.math.BigDecimal" />
</type-mapping>

<table-filter match-catalog="DEV_CSEM_ZAK_SQL" match-schema="DEV_CSEM_ZAK_SQL" match-name="PT_USER" />

<table catalog="DEV_CSEM_ZAK_SQL" schema="DEV_CSEM_ZAK_SQL" name="PT_USER">
  <primary-key>
    <column name="USER_ID" jdbc-type="VARCHAR" property="uniqueId" type="com.perse.onecall.model.key.StringId" />
  </primary-key>
</table>


In version 3.0, this worked just fine. I recently upgraded to 3.1 beta 4 to fix another problem and this no longer works. When this mapping is generated, all columns in the table are added to the composite key class. Has something changed that requires me to update my file? If so, I would appreciate any hints.

Thanks,

Brock


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 30, 2006 7:57 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
if default schema/catalog set to something?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 8:44 am 
Newbie

Joined: Thu Mar 30, 2006 3:48 pm
Posts: 7
I have tried it with and without the default schema and catalog options.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 8:52 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
show me the generated hbm.xml and your cfg.xml file

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 9:26 am 
Newbie

Joined: Thu Mar 30, 2006 3:48 pm
Posts: 7
This is a different table than I mentioned before, but it has the same problem. Here's my cfg:

Code:
<hibernate-configuration>
    <session-factory name="HibernateSessionFactory">
        <property name="hibernate.connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
        <property name="hibernate.connection.password">onecall</property>
        <property name="hibernate.connection.url">jdbc:microsoft:sqlserver://bparkerxp:1433;DatabaseName=DEV_CSEM_ZAK_SQL</property>
        <property name="hibernate.connection.username">DEV_CSEM_ZAK_SQL</property>
        <property name="hibernate.default_schema">DEV_CSEM_ZAK_SQL</property>
        <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
       
        <!-- JDBC connection pool (use the built-in) -->
        <property name="connection.pool_size">1</property>

        <!-- Enable Hibernate's automatic session context management -->
        <property name="current_session_context_class">thread</property>

        <!-- Disable the second-level cache  -->
        <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

        <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">true</property>
    </session-factory>
</hibernate-configuration>


Here is the generated mapping file:

Code:
<hibernate-mapping>
    <class name="com.perse.onecall.model.SmdImplant" table="SMD_IMPLANT" catalog="DEV_CSEM_ZAK_SQL">
        <composite-id name="id" class="com.perse.onecall.model.SmdImplantId">
            <key-property name="smdImplantId" type="string">
                <column name="SMD_IMPLANT_ID" length="16" />
            </key-property>
            <key-property name="caseNo" type="string">
                <column name="CASE_NO" length="16" />
            </key-property>
            <key-property name="codeSmdImplant" type="java.lang.Integer">
                <column name="CODE_SMD_IMPLANT" />
            </key-property>
            <key-property name="smdImplantType" type="java.lang.Integer">
                <column name="SMD_IMPLANT_TYPE" />
            </key-property>
            <key-property name="admittingMd" type="string">
                <column name="ADMITTING_MD" length="16" />
            </key-property>
            <key-property name="primaryCareMd" type="string">
                <column name="PRIMARY_CARE_MD" length="16" />
            </key-property>
            <key-property name="implantDate" type="timestamp">
                <column name="IMPLANT_DATE" length="23" />
            </key-property>
            <key-property name="implantMd" type="string">
                <column name="IMPLANT_MD" length="16" />
            </key-property>
            <key-property name="explantDate" type="timestamp">
                <column name="EXPLANT_DATE" length="23" />
            </key-property>
            <key-property name="explantMd" type="string">
                <column name="EXPLANT_MD" length="16" />
            </key-property>
            <key-property name="description" type="string">
                <column name="DESCRIPTION" length="72" />
            </key-property>
            <key-property name="serialNo" type="string">
                <column name="SERIAL_NO" length="20" />
            </key-property>
            <key-property name="lotNo" type="string">
                <column name="LOT_NO" length="12" />
            </key-property>
            <key-property name="quantity" type="java.lang.Integer">
                <column name="QUANTITY" />
            </key-property>
            <key-property name="systemId" type="string">
                <column name="SYSTEM_ID" length="12" />
            </key-property>
            <key-property name="stockLocation" type="string">
                <column name="STOCK_LOCATION" length="16" />
            </key-property>
            <key-property name="site" type="java.lang.Integer">
                <column name="SITE" />
            </key-property>
            <key-property name="culture" type="string">
                <column name="CULTURE" length="12" />
            </key-property>
            <key-property name="safeMedDeviceSize" type="string">
                <column name="SAFE_MED_DEVICE_SIZE" length="12" />
            </key-property>
            <key-property name="manufacturerId" type="string">
                <column name="MANUFACTURER_ID" length="20" />
            </key-property>
            <key-property name="mfrCatalogNo" type="string">
                <column name="MFR_CATALOG_NO" length="20" />
            </key-property>
            <key-property name="supplierId" type="string">
                <column name="SUPPLIER_ID" length="16" />
            </key-property>
            <key-property name="cost" type="java.math.BigDecimal">
                <column name="COST" precision="15" scale="3" />
            </key-property>
            <key-property name="charge" type="java.math.BigDecimal">
                <column name="CHARGE" precision="15" scale="3" />
            </key-property>
            <key-property name="billingNo" type="string">
                <column name="BILLING_NO" length="20" />
            </key-property>
            <key-property name="pickLocation" type="string">
                <column name="PICK_LOCATION" length="40" />
            </key-property>
            <key-property name="dateReceived" type="timestamp">
                <column name="DATE_RECEIVED" length="23" />
            </key-property>
            <key-property name="expireDate" type="timestamp">
                <column name="EXPIRE_DATE" length="23" />
            </key-property>
            <key-property name="patientExpDate" type="timestamp">
                <column name="PATIENT_EXP_DATE" length="23" />
            </key-property>
            <key-property name="dateSentToMfrFda" type="timestamp">
                <column name="DATE_SENT_TO_MFR_FDA" length="23" />
            </key-property>
            <key-property name="comments" type="string">
                <column name="COMMENTS" length="256" />
            </key-property>
            <key-property name="createUserId" type="string">
                <column name="CREATE_USER_ID" length="16" />
            </key-property>
            <key-property name="createDateTime" type="timestamp">
                <column name="CREATE_DATE_TIME" length="23" />
            </key-property>
            <key-property name="updateUserId" type="string">
                <column name="UPDATE_USER_ID" length="16" />
            </key-property>
            <key-property name="updateDateTime" type="timestamp">
                <column name="UPDATE_DATE_TIME" length="23" />
            </key-property>
            <key-property name="deleteUserId" type="string">
                <column name="DELETE_USER_ID" length="16" />
            </key-property>
            <key-property name="deleteDateTime" type="timestamp">
                <column name="DELETE_DATE_TIME" length="23" />
            </key-property>
            <key-property name="deleteFlag" type="string">
                <column name="DELETE_FLAG" length="1" />
            </key-property>
        </composite-id>
    </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 9:49 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you need to show me a matching set of reveng.xml and hbm.xml

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 9:52 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
anyhow, the problem is most likely that you are setting default schema to the exact same value as used in the table-filter. Don't do that or remove the schema criteria on the table-filter.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 9:59 am 
Newbie

Joined: Thu Mar 30, 2006 3:48 pm
Posts: 7
You are the man!! Once I took all the schema and catalog information out of the reveng.xml file, it worked.

Thank you very much for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 10:10 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the reason is as follows:

if you don't specify default schema/catalog then you will have to be explicit about tables schema/catalog to have us match against them.
This allows us to handle reverse engineering across multiple catalog/schemas.

If you *do* specify default schema/catalog then those tables matching that schema/catalog will be empty/null to be able to match against a reveng.xml with just table names - this allow us to use the same reveng.xml against different single catalog/schemas.

It's suttle i know, but actually works out pretty well in my opinion ;)
(feedback very welcome!)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 10:45 am 
Newbie

Joined: Thu Mar 30, 2006 3:48 pm
Posts: 7
That makes sense. It's not always very easy to find that kind of information though. I was thinking that the default values specified in the cfg.xml file were like fall-back options. If nothing were specified in the reveng.xml file, then it would use the default options. Otherwise, it would use the values in the reveng.xml file. Your way is fine too now that I can see your logic.

Thanks again for your help. Have a great weekend.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 11:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Hi rollingbrock,

I had that logic implemented earlier, but the consequence is then that the metamodel will include full catalog/schema for all tables and thus when you generated from it you will get mapping files that are tied to specific catalog/schema - that is not what you want in most cases.

So, I turned it "around" and now the reveng.xml AND the generated files are reusable across catalog/schema ....yes, it took some time to find the right logic ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 

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.