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.  [ 1 post ] 
Author Message
 Post subject: Invalid SQL generated
PostPosted: Thu May 29, 2008 4:05 pm 
Regular
Regular

Joined: Mon Mar 20, 2006 10:49 pm
Posts: 59
Below is a class mapping for a legacy database (so I can't change the schema). Reading/hydrating the class instances appears to be working perfectly. However, inserting new instances is generating bad SQL - SQL Server complains about duplicate columns in the INSERT command. Seems like a bug. Does anyione have any suggestions for fixes/workarounds?

BTW, I tried tusing NH 2.0 Alpha1, and it also failed, but in a different way (it tried to set the value of the 13th query parameter when the query only had 12 parameters).

Hibernate version:
1.2.1

Mapping documents:

<class name="Milestone" table="ACMILESTNX">
<cache usage="read-only"/>

<composite-id>
<key-many-to-one name="Activity" column="ACTIVITY"/>
<key-property name="MilestoneId" column="MILESTONE"/>
<key-property name="m_milestoneCat" access="field" column="MILESTONE_CAT"/>
</composite-id>

<discriminator column="MILESTONE_CAT" type="String" length="1"/>

<property name="Description" column="DESCRIPTION"/>
<property name="RDate" column="R_DATE"/>
<property name="Days" column="DAYS"/>
<property name="PercComplete" column="PERC_COMPLETE"/>
<property name="BudgetType" column="BUDGET_TYPE"/>
<property name="BillAmount" column="BILL_AMOUNT"/>
<property name="MilestonePct" column="MILESTONE_PCT"/>
<property name="Status" column="STATUS"/>
<property name="LIndex" column="L_INDEX"/>
<property name="LAtmlxSsSw" column="L_ATMLX_SS_SW"/>

<many-to-one name="MilestoneHeader">
<column name="ACTIVITY"/>
<column name="MILESTONE_CAT"/>
</many-to-one>

<subclass name="RevenueMilestone" discriminator-value="R"/>

<subclass name="BillingMilestone" discriminator-value="B"/>

</class>

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

The generated SQL (show_sql=true):
NHibernate.SQL: 2008-05-29 15:58:27,136 [4] DEBUG NHibernate.SQL - INSERT INTO lawson.ACMILESTNX (DESCRIPTION, R_DATE, DAYS, PERC_COMPLETE, BUDGET_TYPE, BILL_AMOUNT, MILESTONE_PCT, STATUS, L_INDEX, L_ATMLX_SS_SW, ACTIVITY, MILESTONE_CAT, MILESTONE_CAT, ACTIVITY, MILESTONE, MILESTONE_CAT) VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10, @p11, 'R', @p12, @p13, @p14); @p0 = 'Delete milestone for Jun, 2007', @p1 = '6/30/2007 12:00:00 AM', @p2 = '0', @p3 = '0', @p4 = '', @p5 = '13374.23', @p6 = '0', @p7 = '1', @p8 = '', @p9 = '', @p10 = 'ALA-DIN-CONT ', @p11 = 'R', @p12 = 'ALA-DIN-CONT ', @p13 = '21A', @p14 = 'R'

_________________
Mike Abraham


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

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.