Postgres inet type [message #980721] |
Sun, 11 November 2012 23:05 |
Neikius Mising name Messages: 43 Registered: April 2011 |
Member |
|
|
So, using eclipselink and inet type is nicely cast to string when reading.
But on insert something is wrong:
Caused by: org.postgresql.util.PSQLException: ERROR: column "..." is of type inet but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
So I must override using descriptor customizer? Is kinda strange since I can insert into that column the IP as normal string.
This gets generated, nothing special (And it dies):
Call: INSERT INTO "table" (columns ...) VALUES (?, ?, ?, ?, ?, ?, ?)
bind => [7 parameters bound]
And this WORKS:
INSERT INTO "table" (columns ...)
VALUES (... '127.0.0.1' ...);
So when I call an ordinary query I can pass inet field as standard string and it all works. When a prepared statement it called via eclipselink and inet is bound as a string everything dies. A bug certiainly, but is there any workaround or a trick to make it work? Converter doesn't seem to work.
|
|
|
|
|
Re: Postgres inet type [message #984694 is a reply to message #980721] |
Wed, 14 November 2012 22:37 |
Neikius Mising name Messages: 43 Registered: April 2011 |
Member |
|
|
Well I can always use a native query and I will for now.
@Chris: Yes it accepts param inet as inline string in a native query. The link you posted doesn't make it exactly clear (I am using java EE!) if I can just use @QueryHint annotation on a @Entity class to override the behaviour just for it? That would be perfect I guess. Does it do escaping if you do it like that automatically?
@James: The problem is I don't know. Manual doesn't say: http://www.postgresql.org/docs/9.2/static/datatype-net-types.html And yea, I am quite sure that is the problem. Strangely though it accepts string inline no problems. I guess I need to take this to postgre people.
[Updated on: Wed, 14 November 2012 22:44] Report message to a moderator
|
|
|
|
Re: Postgres inet type [message #985698 is a reply to message #980721] |
Thu, 15 November 2012 17:40 |
|
You need to add parameter ?stringtype=unspecified to your JDBC connection string. This is due to reason that inets in your query are explicitly casted to Strings by PostgreSQL JDBC driver.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03190 seconds