just for the records... there is not only INET but also CIDR and MACADDR for network stuff in postgresql: http://www.postgresql.org/docs/9.2/static/datatype-net-types.html
the data type supports quite a number of operations (one reason for using these types) so having a dedicated data type might be necessary to support these properly in jOOQ: http://www.postgresql.org/docs/9.2/static/functions-net.html using getByAddress() should indeed be safe Am Freitag, 4. Januar 2013 23:30:25 UTC+1 schrieb Lukas Eder: > > > Thanks for the hint ... works nicely :-) >> > > Good to know > > >> 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. >> > > I think I've seen other databases supporting similar types. It may make > sense to introduce a more formal type support. > Note that jOOQ needs the extra type information to be able to know when to > cast. With VARCHAR / String, that is not possible. Also, converters won't > help in this case. > > >> InetAddress makes sense for mapping into java world, alternatively >> java.lang.String could make sense, too >> > > See above, a distinct DataType / Class is needed to know how to properly > cast it. > > >> Be aware that InetAddress might cause unwanted DNS lookups (eventually >> depending on OS) when instantiating the object. >> > > I was thinking about using this method here: > > http://docs.oracle.com/javase/6/docs/api/java/net/InetAddress.html#getByAddress(byte[]) > > According to the Javadocs, the method doesn't perform any lookups and > doesn't block... > Another option is to introduce a minimal INET implementation in > org.jooq.types, similar to unsigned integers and interval data types. >
