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.  [ 2 posts ] 
Author Message
 Post subject: NHibernet insert query fails
PostPosted: Mon Jun 23, 2008 12:19 pm 
Newbie

Joined: Sun Jun 22, 2008 11:08 pm
Posts: 2
Hi,

This is first time I am using Nhibernet.
This is how I have defined my xml file
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false">

<class name="myVRM.DataLayer.vrmCustomAttributes, vrmDataLayer" table="Dept_CustomAttr_Option_D">

<id name="OptionID" column="OptionID" type="Int32" unsaved-value="0">
<generator class="identity" />
</id>
<!-- Map properties I'd like to persist/fetch, assume column = propery name, and type is determined by reflection -->
<property name="CustomAttributeID"/>
<property name="DeptID"/>
<property name="OptionType"/>
<property name="OptionID"/>
<property name="OptionValue"/>
<property name="Caption"/>
<property name="HelpText"/>
</class>
</hibernate-mapping>

Now my problem is when I am trying to enter a new record in table it does not takes the [b]OptionID [/b]as part of insert query and it fails.
Now if i remove the Id property from xml it gives me error because that is a mandotary field.option id is a not null field and it should be unique for each cust id+option type combination.

I got this error [b]ERROR NHibernate.Util.ADOExceptionReporter - LogExceptions:Value cannot be null.
Parameter name: id[/b]

Please help me how to resolve this issue


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 23, 2008 8:55 pm 
Newbie

Joined: Mon Jun 23, 2008 6:38 pm
Posts: 13
Can you tell me what the reason is for you to use "identity" for OptionID ? By looking at the error message, I guess OptionID is a primary key of the table, and it's auto-incremental because you didn't assign any value to it. Did you try <generator class="native" /> ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.