Search code examples
mysqljdodatanucleus

Datanucleus JDO + MySQL create longtext column


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.


Solution

  • 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.