异常描述:ejb3.0程序中使用jpa做持久化,使用的数据库为sql server2000,在jboss中部署。在查询Client这个实体的时候,抛出以下异常
-----------------------------------------------------------------------------
 2010-05-06 17:08:42,640 INFO  [org.hibernate.type.StringType] could not read column value from result set: memo0_0_; [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
2010-05-06 17:08:42,640 WARN  [org.hibernate.util.JDBCExceptionReporter] SQL Error: 0, SQLState: S1002
2010-05-06 17:08:42,640 ERROR [org.hibernate.util.JDBCExceptionReporter] [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
2010-05-06 17:08:42,640 INFO  [org.hibernate.event.def.DefaultLoadEventListener] Error performing load command
org.hibernate.exception.GenericJDBCException: could not load an entity: [com.xxx.Client#3]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1874)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
------------------------------------------------------
其中Client实体定义(部分代码)
-----------------------------------------------------------------
@Id
   @GeneratedValue(strategy=GenerationType.AUTO)
   private Long id;
   @Transient
   protected boolean create;
//   private String memo;
   private boolean deleteFlag;
  private String code; 
    private String fullName; 
    private String tel;
    private String fax;
   
    @OneToOne
    private Area area;
    @Transient
    private String areaName;-----------------------------------------------------------------以上定义的实体,在使用mysql数据库时不会出现以上异常,请各位帮忙分析一下,谢谢了!还有在jboss中部署的时候,会出现jpa不能自动更新表结构的情况,异常代码如下:
-------------------------------------------------------------
2010-05-06 17:00:43,421 INFO  [org.hibernate.tool.hbm2ddl.SchemaUpdate] updating schema
2010-05-06 17:00:43,484 WARN  [org.hibernate.util.JDBCExceptionReporter] SQL Error: 0, SQLState: S1002
2010-05-06 17:00:43,484 ERROR [org.hibernate.util.JDBCExceptionReporter] [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
2010-05-06 17:00:43,484 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] could not complete schema update
org.hibernate.exception.GenericJDBCException: could not get table metadata: client
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at org.hibernate.tool.hbm2ddl.DatabaseMetadata.getTableMetadata(DatabaseMetadata.java:105)
at org.hibernate.cfg.Configuration.generateSchemaUpdateScript(Configuration.java:948)
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:140)
--------------------------------------------------------------

解决方案 »

  1.   

    有两点比较可疑:
    1、
    private Long id;
    'id' 是SQL Server 2000的关键词,似乎Sp3以下的补丁都对其敏感,不能创建表。
    另外检查下orm的方言,Long会映射到SQL Server 2000哪种类型,且SQL Server 2000数据库中这种类型支不支持自增长。2、
    @OneToOne
    private Area area;
    这样简单配置不太可靠。加上@JoinColumn和级联配置试试。同样还得检查Area.class中对应的配置(单向的就不用)
      

  2.   

    回楼上:
    1,Long类型会映射成为sql server2000的bigint类型,使用过程中“id”此类关键字没问题,自增长也没问题。
    2,发现唯一的问题是设置了@OneToOne的字段,可能跟配置有关,这几天有点忙,暂且先绕过去。等过几天再试试,看有没可能解决,能解决就贴上方法。谢谢楼上。(不知怎么给分,是否是结贴后才能分配?晚点再给了)