Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Coping with non standard data types on insert/update

You can customize your insert (or update/delete/read) SQL using a
DescriptorCustomizer and the ClassDescriptor's DescriptorQueryManager's
setInsertSQLString() API.

descriptor.getQueryManager().setInsertSQLString("INSERT into table
(cidrfield) values(#CIDRFIELD ::cidr)");

You may also want to vote for getting annotation and xml support for this,

Tim Hollosy wrote:
> I wasn't sure if that was what I wanted, they seemed to be XML
> specific from the examples, plus the more I thought of it, the more I
> knew it was more of a postgres JDBC problem since there is no native
> type that maps to an inet or cidr in java.
> What I ended up doing was creating a view with an insert rule that
> does the cast for me, cuz postgres is crazy like that :)
> Really the only thing that could help me would be a way to modify the
> SQL used for insert statements (so I could add a cast like ?::cidr to
> my bind) on a specific entity and I didn't see anything like that.
> Thanks,
> Tim
> On Tue, Jun 3, 2008 at 3:01 PM, Mohsen Saboorian <mohsens@xxxxxxxxx>
> wrote:
>> Did you try converters?
>> Mohsen.
>> On Tue, Jun 3, 2008 at 5:46 PM, Tim Hollosy <hollosyt@xxxxxxxxx> wrote:
>>> I've got a table with a cidr datatype (postgres), on selects JPA maps
>>> it to a String, which is fine. However on inserts/updates this of
>>> course does not work.
>>> In the past (pure jdbc) I'd simply cast like so, "INSERT into table
>>> (cidrfield) values(?::cidr)" what's the best practices for dealing
>>> with custom datatypes that aren't mapped by eclipselink/jpa?
>>> Will I have to write insert queries by hand for all my inserts or is
>>> there an elegant way? I was looking at the Converter annotations, but
>>> that looks like it's for XML stuff only.
>>> Thanks,
>>> Tim

--- James Sutherland
 EclipseLink ,
Wiki: EclipseLink , TopLink 
Forums: TopLink , EclipseLink 
Book: Java Persistence 
View this message in context:
Sent from the EclipseLink - Users mailing list archive at

Back to the top