1, could not initialize proxy-no session.
Reason: The default option for Hibernate3 many-to-one is lazy = "Proxy"
> Solution:<many-to-one> & <set> Set lazy= "false"
In fact, only in <many-to-one> set lazy= "false" on it, the set also sets the words will be more than one query.
>2, table with no primary key how to write. Hbm.xml configuration file
> has. hbm.xml configuration requires a
<id name= "id" >
<generator class= "GUID" ></generator>
</id>
No <id> configuration section will complain, but some tables do not have a primary key.
For example, some from a table, such as a list of orders, in most cases, do not require a primary key.
In fact, no <id> can also, but need to have <composite-id>, that is, the joint primary key. A federated primary key is a few attributes uniquely identifying the current record.
In another way, add all the attributes together as a joint primary key.
<composite-id>
<key-property name= "Amount" ></key-property>
<key-property name= " Createtime "></key-property>
<key-property name=" Modifytime "/>
</composite-id>
3, after the joint primary key need to pay attention to place
The corresponding model needs to implement the Equals and GetHashCode method after using the Union primary key, otherwise it will be an error.
public override bool Equals (object obj)
{
var item = obj as Crmtypecustomer;
return this. Crmtypeid = = Item. Crmtypeid
&& this. CustomerID = = Item. CustomerID;
}
public override int GetHashCode ()
{return
base. GetHashCode ();
}
4, index 4 of this sqlserverparametercollection's count=4 is invalid
The reason is:
The problem when the primary table is associated from a table.
<many-to-one name= "dictate" column= "Dictateid" class= "Model.jkptoaxtdictate,model"/>
Modified to:
<many-to-one name= "dictate" column= "Dictateid" class= "Model.jkptoaxtdictate,model" insert= "false" update= "false" />
That is, add a property
Insert= "false" update= "false"