Am Freitag, 4. Januar 2013 22:46:11 UTC+1 schrieb Lukas Eder:
>
> Hello,
>
> >> ERROR: column "created_ip" is of type inet but expression is of type 
> character varying
>
>> >>  Hint: You will need to rewrite or cast the expression.
>>
>> Is there a way to solve this issues?
>>
>
> The easiest workaround is to write this:
>
> factory.insertInto(REGISTRATION)
> .set(REGISTRATION.EMAIL, "[email protected] <javascript:>")
>  .set(REGISTRATION.PASSWORD_HASH, "2304820984309238409237428739")
> .set(REGISTRATION.CREATED_IP, field("?::inet", String.class, "::1"))
>  .execute();
>
> By using plain SQL, you can cast bind values to custom data types
>
> Should type INET be supported by jooq natively?
>>
>
> It probably should, I have created #2092 for this:
> https://github.com/jOOQ/jOOQ/issues/2092
>
> So far, I'm not quite sure how to handle these dialect-specific data 
> types, that are not really compatible with any of java.sql.Types' types. 
> Specifically, Postgres and the Postgres JDBC driver have their ways of 
> dealing with these non-standard situations.
>
> Any implementation hint for #2092 is very welcome
>
> Cheers
> Lukas
>


Thanks for the hint ... works nicely :-)

Maybe you should use VARCHAR as the SQL data type and convert the value 
using CAST(? as inet) and CAST(? as text) when sending / receiving an inet 
address from the database.

InetAddress makes sense for mapping into java world, alternatively 
java.lang.String could make sense, too

Be aware that InetAddress might cause unwanted DNS lookups (eventually 
depending on OS) when instantiating the object.

Reply via email to