-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Wie ein char(10) mappen?
PostPosted: Thu Jul 19, 2007 6:57 am 
Beginner
Beginner

Joined: Thu Jun 14, 2007 4:33 am
Posts: 39
Hallo,

ich verwende Hibernate 3 und versuche gerade eine bestehende Datenbank (Postgres 8.2) zu mappen. Leider scheitert es an einem bestimmten Feld in der Datenbank, einem char(10)

Irgendwie finde ich nicht das richtige Mapping für diesen Datentyp, aus der API-Referenz hab ich nur Mappings für varchar und char(1) gefunden.

Code:
public Character[] getSignup_date(){..}
public void setSignup_date(Character[] signup_date){..}
...
private Character[] _signup_date;


Code:
<property name="signup_date"
                          column="signup_date"
                          type="character"
                          .../>

Code:
create table foobar(
....
signup_date CHAR(10) NULL,
...);


Code:
org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of dao.impl.HibernateUbAccountDAOImpl.signup_date
   at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:104)
   at org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:337)
   at org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:200)
   at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3566)
   at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:129)
   at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:854)
   at org.hibernate.loader.Loader.doQuery(Loader.java:729)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
   at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
   at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
   at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
   at org.hibernate.loader.entity.BatchingEntityLoader.load(BatchingEntityLoader.java:82)
   at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3044)
   at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395)
   at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
   at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
   at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195)
   at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
   at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
   at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:846)
   at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:557)
   at org.hibernate.type.EntityType.resolve(EntityType.java:379)
   at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)
   at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:854)
   at org.hibernate.loader.Loader.doQuery(Loader.java:729)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
   at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
   at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
   at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
   at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3044)
   at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395)
   at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
   at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
   at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:98)
   at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
   at org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:836)
   at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:66)
   at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
   at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150)
   at dao.impl.HibernateBjAccountDAOImpl$$EnhancerByCGLIB$$e6be6a5d.getUnumber(<generated>)
   at dao.impl.HibernateBjAccountDAOImpl.getBjAccount(HibernateBjAccountDAOImpl.java:31)
   at Main.main(Main.java:20)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Caused by: java.lang.IllegalArgumentException: argument type mismatch
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42)
   ... 46 more

Process finished with exit code 1


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 06, 2007 9:29 am 
Newbie

Joined: Tue Jul 31, 2007 8:37 am
Posts: 12
Ich denke so müsste es funktionieren:

Code:
...
<property name="signup_date">
     <column name="signup_date" sql-type="CHAR(10)"/>
</property>


In der Methode set/get-Signup_date würde ich es aber als String übergeben!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.