做以下
// Notice without @Lob
@Column(length=4000)
private String getIntroText() {
return this.introText;
}
在剧本后,我看到
IntroText TEXT
因此预期这是行不通的。所以我的建议是:使用columnDefinition属性,而不是
它允许您定义确切的DDL用于定义列类型
@Lob
@Column(columnDefinition="TEXT (4000)")
private String getIntroText() {
return this.introText;
}
现在它工作正常!你可以测试你是否想要
AnnotationConfiguration configuration = new AnnotationConfiguration();
configuration
.addAnnotatedClass(<YOUR_ENTITY_GOES_HERE>.class)
.setProperty(Environment.HBM2DDL_AUTO, "create")
.setProperty(Environment.USER, "<USER_GOES_HERE>")
.setProperty(Environment.PASS, "<USER_PASS_GOES_HERE>")
.setProperty(Environment.SHOW_SQL, "true")
.setProperty(Environment.FORMAT_SQL, "true")
// Set up your dialect according to the Target MySQL
.setProperty(Environment.DIALECT, "org.hibernate.dialect.MySQLDialect")
.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver")
.setProperty(Environment.URL, "jdbc:mysql://127.0.0.1:3306/<YOUR_SCHEMA_GOES_HERE>");
SchemaExport schema = new SchemaExport(configuration);
schema.setOutputFile("schema.sql");
schema.create(true, true);
只是一个建议:如果可能的话,把注释配置放在getter方法而不是成员字段。 Hibernate使用代理来完成你的工作。在getter方法中使用注释配置时,它工作正常。
问候,
“只是一个建议:如果可能的话,把注释配置getter方法,而不是成员领域Hibernate使用代理服务器做你的工作,它的getter方法使用注释配置时工作得很好。”是什么伎俩。我在属性上有注释,而不是吸气剂。 谢谢! – lupefiasco 2010-02-02 23:46:26