Found solution here:
http://www.hibernate.org/Documentation/ ... 2AndOracle
My question is, how do I correctly use Annotations with my userType?
I have:
@org.hibernate.annotations.Type(
type = "persistent.types.FooType"
)
@Column(name = "Foo", nullable = false, length = 10)
private FooType foo;
The logs show that my trim is not happening.
and I get:
[emmajava] Caused by: org.hibernate.PropertyAccessException: could not set a field value by reflection setter of persistent.entities.Baz.foo
[emmajava] at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:82)
[emmajava] at org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:337)
[emmajava] at org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:200)
[emmajava] at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3564)
[emmajava] at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:129)
[emmajava] at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:854)
[emmajava] at org.hibernate.loader.Loader.doQuery(Loader.java:729)
[emmajava] at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
[emmajava] at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
[emmajava] at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
[emmajava] at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
[emmajava] at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3042)
[emmajava] at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395)
[emmajava] at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
[emmajava] at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
[emmajava] at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195)
[emmajava] at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
[emmajava] at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
[emmajava] at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815)
[emmajava] at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808)
[emmajava] at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:175)
[emmajava] ... 26 more
[emmajava] Caused by: java.lang.IllegalArgumentException
[emmajava] at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
[emmajava] at java.lang.reflect.Field.set(Field.java:656)
[emmajava] at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:79)
[emmajava] ... 46 more
do I need to user a hibernate mapping xml?
----
was =>
Hibernate annotations 3.3.0.GA, Hibernate Core 3.2.3, Oracle 10g
For this Mapping:
@Column(name = "FOO", nullable = false, length = 10)
private String foo;
I get:
(extra 20 whitespace characters)
[DEBUG] (main) org.hibernate.type.StringType: returning '1234567890 ' as column: FOO1_
Tue Jul 10 21:53:44 2007 GMT MyTest 11931-0@desktop:0 [ERROR] (main) org.hibernate.util.JDBCExceptionReporter: ORA-12899: value too large for column "schema"."bar"."foo" (actual: 30, maximum: 10)
The oracle DDL is:
"FOO" CHAR(10 CHAR) NOT NULL ENABLE,
How do I tell Hibernate the column really is only a char(10)?
Thanks
-Steve