Hi. I have a problem mapping an identity column that is not a key. I donĀ“t want hibernate to insert or update the value from column Number, however I want it to be retrieved.
BR
Alex
--DB SQL Server 2005
CREATE TABLE [dbo].[abc](
[Id] [uniqueidentifier] NOT NULL, --(Primary Key)
[Number] [int] IDENTITY(1,1) NOT NULL,
[Name] [varchar](1)
//Hibernate mapping
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="abc, abc" table="abc" lazy="true">
<id name="Id" column="Id" type="System.Guid" unsaved-value="00000000-0000-0000-0000-000000000000">
<generator class="guid" />
</id>
<property name="Number" column="Number" type="System.Int32" not-null="false" />
<property name="Name" column="Name" type="System.String" not-null="true" />
</class>
</hibernate-mapping>
//c#
public class abc
{
private Guid m_id;
private int m_number;
private string m_name;
public Guid Id
{
get { return m_id; }
set { m_id = value; }
}
public int Number
{
get { return m_number; }
set { m_number = value; }
}
public string Name
{
get { return m_name; }
set { m_name = value; }
}
|