NHibernate를 배우기 시작했습니다. 최신 버전이 설치되어 있고 아주 간단한 응용 프로그램을 실행하려고합니다.사용자를 삽입하는 동안 "쿼리를 구문 분석하는 동안 오류가 발생했습니다"
public class User
{
public virtual Guid Id { get; set; }
public virtual String Name { get; set; }
public virtual int Age { get; set; }
public override string ToString()
{
return string.Format("User{name='{0}', age={1}}", Name, Age);
}
}
그것의 매핑은 다음과 같습니다 : 클래스 User
있다
class Program
{
static void Main(string[] args)
{
var cfg = new Configuration();
cfg.Configure();
cfg.AddAssembly(typeof (User).Assembly);
new SchemaExport(cfg).Execute(false, true, true);
ISessionFactory sessionFactory = cfg.BuildSessionFactory();
using (ISession session = sessionFactory.OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
User user = new User { Name = "John Smith", Age = 25 };
session.Save(user);
transaction.Commit();
}
}
}
}
그리고있는 hibernate.cfg.xml은 다음과 같이이다 : 다음
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="cs_nhibernate_test1"
namespace="cs_nhibernate_test1">
<class name="User">
<id name="Id">
<generator class="guid" />
</id>
<property name="Name" />
<property name="Age" />
</class>
</hibernate-mapping>
, 내 테스트 프로그램은 다음과 같이이다
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.MsSqlCeDialect</property>
<property name="connection.driver_class">NHibernate.Driver.SqlServerCeDriver</property>
<property name="connection.connection_string">Data Source=FirstSample.sdf</property>
<property name="show_sql">true</property>
</session-factory>
프로젝트가 .NET 4.0 프로젝트 인 경우 모든 필요한 파일 은이 출력 폴더에있는 것처럼 보입니다.
내가 오류는 다음과 같습니다
NHibernate에가 : 사용자 삽입 반 (이름, 나이, Id)을 VALUES (@ P0, @ P1, @ P2) @ P0 = '존 스미스'[유형 : 문자열 (0)] @ P1 = 25 [유형 : INT32 (0)] @ P2 = 4b0d4bbf- 7d3c-4bff-908D-ecddfdd8a5cd [형식의 GUID (0)]
되지 않은 예외 : 시스템. Data.SqlServerCe.SqlCeException : 거기에 쿼리 구문 분석 오류가 발생했습니다. [토큰 줄 번호 = 1, 토큰 줄 오프셋 = 13, 오류가있는 토큰]
해결에 대한 아이디어가 있으십니까?
omfg, 당신은 절대적으로 옳습니다. 감사! – agibalov