I did some digging and what I was able to determine is that Hibernate sends a parameter with type java.sql.Types.VARBINARY, so the Postgre JDBC driver does use it correctly. Hibernate is supposed to send a parameter type java.sql.Types.NULL.
Problem: AbstractQueryImpl.java: (as of 4.3.6 Final)
474 public Query setParameter(int position, Object val) throws HibernateException { 475 if (val == null) { 476 setParameter( position, val, StandardBasicTypes.SERIALIZABLE ); 477 }
478 else { 479 setParameter( position, val, determineType( position, val ) ); 480 }
481 return this; 482 } 483 484 public Query setParameter(String name, Object val) throws HibernateException { 485 if (val == null) { 486 Type type = parameterMetadata.getNamedParameterExpectedType( name ); 487 if ( type == null ) { 488 type = StandardBasicTypes.SERIALIZABLE; 489 }
490 setParameter( name, val, type ); 491 } 492 else { 493 setParameter( name, val, determineType( name, val ) ); 494 }
495 return this; 496 }
StandardBasicTypes.SERIALIZABLE has sqlTypes[] containing java.sql.Types.VARBINARY;
We need a StandardBasicTypes.NULL who's sqlTypes[] must contain java.sql.Types.NULL And we need it used in at least those two functions. Possibly more.
Of course I wouldn't need this fix so badly if the @AttributeOverride annotation worked as all the docs say it should. No matter what I tried I could not get that attribute (which is a limited 1 level recursion on it's own class) to be saved in it's own column.
|