Click here to Skip to main content
16,004,919 members
Home / Discussions / Database
   

Database

 
GeneralHelp with MS SQL Update statement please. Pin
Steven J Jowett30-Jan-08 2:03
Steven J Jowett30-Jan-08 2:03 
GeneralRe: Help with MS SQL Update statement please. Pin
Steven J Jowett30-Jan-08 2:18
Steven J Jowett30-Jan-08 2:18 
GeneralRe: Help with MS SQL Update statement please. Pin
Ashfield30-Jan-08 2:21
Ashfield30-Jan-08 2:21 
GeneralRe: Help with MS SQL Update statement please. Pin
Steven J Jowett30-Jan-08 5:21
Steven J Jowett30-Jan-08 5:21 
GeneralRe: Help with MS SQL Update statement please. Pin
Ashfield30-Jan-08 7:22
Ashfield30-Jan-08 7:22 
QuestionHow Can I execute pl/sql query?? Pin
Vanamaindia29-Jan-08 23:09
Vanamaindia29-Jan-08 23:09 
AnswerRe: How Can I execute pl/sql query?? Pin
andyharman29-Jan-08 23:26
professionalandyharman29-Jan-08 23:26 
GeneralNHibernate data saving problem, help! Pin
Harry Sun29-Jan-08 22:56
Harry Sun29-Jan-08 22:56 
Hi, I am in the trouber of the error while the project trys to saving the data to child table. The error message
is shown below:

NHibernate.ADOException: could not insert: [ConsoleApplication1.user][SQL: INSERT INTO user (UNAME, NID) VALUES (?, ?)] --->

So confused that why it cannot get values to save. NHibernate I used is version 1.2. The code files are list below, please help me out here.
Thanks in advance.

app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.2.0.4000,Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</configSections>
<nhibernate>
<add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
<add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2005Dialect"/>
<add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver"/>
<add key="hibernate.connection.connection_string" value="Server=;initial catalog=;Persist Security Info=True;User ID=;Password="/>
</nhibernate>
</configuration>

user.hbm.xml:

<hibernate-mapping default-cascade="none" xmlns="urn:nhibernate-mapping-2.2">
<class name="ConsoleApplication1.user, ConsoleApplication1" table="user">
<id name="UID" type="System.Int32" column="UID" unsaved-value="0">
<generator class="native" />
</id>
<property name="UNAME" type="System.String" column="UNAME" not-null="false" />
<many-to-one name="Nationality" class="ConsoleApplication1.nationality, ConsoleApplication1" fetch="select" cascade="all">
<column name="NID" not-null="false" />
</many-to-one>
</class>
</hibernate-mapping>

user.hbm.cs:

namespace ConsoleApplication1 {


[System.SerializableAttribute()]
public class Abstractuser {

private int uID;

private string uNAME;

private ConsoleApplication1.nationality nationality;

public virtual int UID {
get {
return this.uID;
}
set {
this.uID = value;
}
}

public virtual string UNAME {
get {
return this.uNAME;
}
set {
this.uNAME = value;
}
}

public virtual ConsoleApplication1.nationality Nationality {
get {
return this.nationality;
}
set {
this.nationality = value;
}
}
}

[System.SerializableAttribute()]
public partial class user : Abstractuser {
}
}

nationality.hbm.xml:

<hibernate-mapping default-cascade="none" xmlns="urn:nhibernate-mapping-2.2">
<class name="ConsoleApplication1.nationality, ConsoleApplication1" table="nationality">
<id name="NID" type="System.Int32" column="NID" unsaved-value="0">
<generator class="native" />
</id>
<property name="NATIONALITY" type="System.String" column="NATIONALITY" not-null="false" />
<bag name="User" inverse="true" lazy="true" cascade="all">
<key>
<column name="NID" not-null="false" />
</key>
<one-to-many class="ConsoleApplication1.user, ConsoleApplication1" />
</bag>
</class>
</hibernate-mapping>

nationality.hbm.cs:

namespace ConsoleApplication1 {


[System.SerializableAttribute()]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ConsoleApplication1.user))]
[System.Xml.Serialization.SoapIncludeAttribute(typeof(ConsoleApplication1.user))]
public class Abstractnationality {

private int nID;

private string nATIONALITY;

private System.Collections.IList user;

public virtual int NID {
get {
return this.nID;
}
set {
this.nID = value;
}
}

public virtual string NATIONALITY {
get {
return this.nATIONALITY;
}
set {
this.nATIONALITY = value;
}
}

public virtual System.Collections.IList User {
get {
return this.user;
}
set {
this.user = value;
}
}
}

[System.SerializableAttribute()]
public partial class nationality : Abstractnationality {
}
}

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{

NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
cfg.AddAssembly("ConsoleApplication1");
ISessionFactory factory = cfg.BuildSessionFactory();
ISession session = factory.OpenSession();
ITransaction transaction = session.BeginTransaction();


nationality nat = (nationality)session.Get(typeof(nationality), 1);

user u = new user();
u.UNAME = "Pall";
u.Nationality = nat;
nat.User.Add(u);

try
{
if (!session.IsConnected)
{
session.Reconnect();
}

session.Save(u); // Error occured at this line!!

transaction.Commit();
session.Close();
}
catch (Exception e)
{
string s = e.ToString();
}
}


}
}
GeneralRe: NHibernate data saving problem, help! Pin
Mark Churchill30-Jan-08 2:10
Mark Churchill30-Jan-08 2:10 
Questionhow to store result of exec(query) values in to a temp table Pin
veereshIndia29-Jan-08 21:04
veereshIndia29-Jan-08 21:04 
AnswerRe: how to store result of exec(query) values in to a temp table Pin
Ashfield29-Jan-08 21:23
Ashfield29-Jan-08 21:23 
GeneralRe: how to store result of exec(query) values in to a temp table Pin
veereshIndia29-Jan-08 22:15
veereshIndia29-Jan-08 22:15 
QuestionRe: how to store result of exec(query) values in to a temp table Pin
Ashfield29-Jan-08 22:30
Ashfield29-Jan-08 22:30 
GeneralRe: how to store result of exec(query) values in to a temp table Pin
veereshIndia29-Jan-08 22:39
veereshIndia29-Jan-08 22:39 
GeneralRe: how to store result of exec(query) values in to a temp table Pin
veereshIndia30-Jan-08 1:43
veereshIndia30-Jan-08 1:43 
GeneralRe: how to store result of exec(query) values in to a temp table Pin
Ashfield30-Jan-08 2:01
Ashfield30-Jan-08 2:01 
Generalpdf format Pin
sandhya1429-Jan-08 19:39
sandhya1429-Jan-08 19:39 
GeneralRe: pdf format Pin
pmarfleet29-Jan-08 22:04
pmarfleet29-Jan-08 22:04 
GeneralRe: pdf format Pin
sandhya1429-Jan-08 22:19
sandhya1429-Jan-08 22:19 
GeneralRe: pdf format Pin
Pete O'Hanlon29-Jan-08 22:10
mvePete O'Hanlon29-Jan-08 22:10 
QuestionUsing SP In MS SQL Server2000 Pin
Arunika De Jonk29-Jan-08 18:33
Arunika De Jonk29-Jan-08 18:33 
AnswerRe: Using SP In MS SQL Server2000 Pin
Ashfield29-Jan-08 22:09
Ashfield29-Jan-08 22:09 
GeneralRe: Using SP In MS SQL Server2000 Pin
Arunika De Jonk29-Jan-08 22:17
Arunika De Jonk29-Jan-08 22:17 
GeneralRe: Using SP In MS SQL Server2000 Pin
pmarfleet29-Jan-08 22:15
pmarfleet29-Jan-08 22:15 
GeneralRe: Using SP In MS SQL Server2000 Pin
Arunika De Jonk29-Jan-08 22:20
Arunika De Jonk29-Jan-08 22:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.