Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] DynamicEntity and arbitrary-length text fields

You are right. I also found DynamicEntity does not support clob/blob. You could add a custom type for your text. The custom type is basically a wrapper for a text field.  You need a Converter for this custom type, too. Here is how I support for binary file: https://github.com/jasonzhang2022/flexims/tree/master/common/src/main/java/com/flexdms/flexims/jpa/helper.

-jason

On Fri, Oct 3, 2014 at 9:21 AM, David North <dtn-eclipselink-users@xxxxxxxxxxxxxxxx> wrote:
If I'm using normal JPA-annotated entities and I want to store an
arbitrary-length string, it's straightforward: I annotate the relevant
string getter with @javax.persistence.Lob, and the right thing happens.

If I'm using DynamicEntity, I can't work out how to do the equivalent.

The closest I've come is to build the type like this:

typeBuilder.addDirectMapping("long_text", java.sql.Clob.class, "long_text")

I can then use EntityManager.unwrap to get hold of a java.sql.Connection
on which I can use createClob to create values for the mapping I've added.

Unfortunately, this falls short when my JDBC driver doesn't implement
createClob. Ideally I'd like an equivalent to the @Lob annotation, which
*does* work - presumably by using setCharacterStream on a
PreparedStatement somewhere under the hood.

Any suggestions?

Many thanks,
David
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/eclipselink-users



--
-jiesheng

Back to the top