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.

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

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

https://bugs.eclipse.org/bugs/show_bug.cgi?id=226519



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?
>> http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_(ELUG)#Using_EclipseLink_JPA_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
> 


-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/Coping-with-non-standard-data-types-on-insert-update-tp17624627p17648187.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top