Datanucleus JDO + MySQL创建长文本列
我正在尝试在我自己的Java项目(而不是GAE)中使用DataNucleus的JDO,并且我需要在我的数据库中存储相当长的文本片段。
我正在使用 Eclipse 来完成所有脏活,例如增强和创建模式,但不幸的是,所有 String
ivars 都映射到 VARCHAR
列。但是我如何让 Datanucleus 为我创建一个 LONGTEXT
列?
我还尝试了 @Colunn
注释,但我仍然得到 VARCHAR
。
<代码>
@Persistent
@Column(name="COMPONENT", jdbcType="LONGVARCHAR", length=1000000)
private String component;
我还尝试将 LONGTEXT
指定为 jdbcType
,但 Schematool 告诉我,无法使用该数据类型。
预先感谢您,
新年快乐,
谨致问候,
蒂莫菲。
I am trying to use DataNucleus's JDO in my own Java project (not GAE), and i need to store quite long pieces of text in my DB.
I am using Eclipse to do all the dirty work, like enhancing and creating the schema, but unfortunately, all String
ivars are mapped to VARCHAR
columns. But how do i get Datanucleus to create a LONGTEXT
column for me?
I also tried the @Colunn
annotation, but i still got the VARCHAR
.
@Persistent @Column(name="COMPONENT", jdbcType="LONGVARCHAR", length=1000000) private String component;
I also tried specifying LONGTEXT
as jdbcType
, but the Schematool informed me, that that datatype could not be used.
Thank you in advance,
Happy New Year,
Best regards,
Timofey.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
LONGTEXT 不是 JDBC 类型。它们都在 http://docs.oracle 中清楚地列出.com/javase/6/docs/api/java/sql/Types.html
DataNucleus 日志告诉您该 JDBC 驱动程序可以使用哪些 JDBC 类型(因为它将该信息提供给使用软件)。它选择将 JDBC 类型 LONGVARCHAR 映射到“LONG VARCHAR”IIRC(通过使用 SchemaTool“dbinfo”可以轻松查看)。显然,您可以将模式生成到文本文件中,并在应用之前自行更新。
LONGTEXT is not a JDBC type. They are all clearly listed in http://docs.oracle.com/javase/6/docs/api/java/sql/Types.html
The DataNucleus log tells you what JDBC types are available for that JDBC driver (since it provides that information to the utilising software). It chooses to map JDBC type LONGVARCHAR onto "LONG VARCHAR" IIRC (easily visible by using SchemaTool "dbinfo"). You could obviously generate the schema into a text file and update it yourself before applying it.
数据类型 CLOB 映射到中等文本。但是一旦创建了数据库,您可以将其更改为 LONGTEXT
The data type CLOB maps to medium text. But once the database is created you can change it to LONGTEXT