Datanucleus JDO + MySQL创建长文本列

发布于 2024-12-23 14:34:28 字数 604 浏览 6 评论 0原文

我正在尝试在我自己的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

倾城月光淡如水﹏ 2024-12-30 14:34:28

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.

鹿! 2024-12-30 14:34:28
@Persistent
@Column(name="COMPONENT", jdbcType="CLOB")
private String component;

数据类型 CLOB 映射到中等文本。但是一旦创建了数据库,您可以将其更改为 LONGTEXT

@Persistent
@Column(name="COMPONENT", jdbcType="CLOB")
private String component;

The data type CLOB maps to medium text. But once the database is created you can change it to LONGTEXT

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文