昨天下载了最新的hibernate包,3.6.0 CR2,与spring 3.0.4集成使用,jdk1.6,一运行,报javax.persistence.EntityListner找不到的错误。hibernte的包里面不带这个类,于是去网上找了个javax.persistence的jar。再运行,又报错:setString can only process strings of less than 32766 chararacters我的表有两个字段,一个number类型, 一个clob类型。我使用老的hibernate 包(3.3.0)一点问题也没有。怎么弄呢?
<hibernate-mapping package="dbtest">
<class name="SubFile" table="SUB_FILE" lazy="true">
<id name="objId" column="OBJ_ID">
<generator class="sequence"></generator>
</id>
<property name="fileContent" not-null="true" type="text" column="CONTENT"/>
</class>
</hibernate-mapping>public class SubFile {
private long objId;
private String fileContent;
public long getObjId() {
return objId;
}
public void setObjId(long objId) {
this.objId = objId;
}
public String getFileContent() {
return fileContent;
}
public void setFileContent(String fileContent) {
this.fileContent = fileContent;
}
}
<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="myDataSource"/>
<property name="mappingResources">
<list>
<value>dbtest/SubFile.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.connection.SetBigStringTryClob">true</prop>
</props>
</property>
</bean>
<hibernate-mapping package="dbtest">
<class name="SubFile" table="SUB_FILE" lazy="true">
<id name="objId" column="OBJ_ID">
<generator class="sequence"></generator>
</id>
<property name="fileContent" not-null="true" type="text" column="CONTENT"/>
</class>
</hibernate-mapping>public class SubFile {
private long objId;
private String fileContent;
public long getObjId() {
return objId;
}
public void setObjId(long objId) {
this.objId = objId;
}
public String getFileContent() {
return fileContent;
}
public void setFileContent(String fileContent) {
this.fileContent = fileContent;
}
}
<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="myDataSource"/>
<property name="mappingResources">
<list>
<value>dbtest/SubFile.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.connection.SetBigStringTryClob">true</prop>
</props>
</property>
</bean>
要与时俱进啊。忘了提一句,数据库是oracle 10g。spring 3的手册变化很大,全面推广annotation,新版本,一般会修正bug,增加功能,提高性能,用新版本还是有它的道理的。