-->
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: InstantiationException
PostPosted: Thu Jul 03, 2008 9:43 am 
Newbie

Joined: Thu Jul 03, 2008 9:19 am
Posts: 2
Hallo,
ich habe vor kurzem angefangen, Hibernate zu benutzen.
Mithilfe von Annotations habe ich jetzt 2 Entity-Klassen geschrieben: Player und Team, wobei Team ein Fremdschlüssel in Player ist.

Beim Laden eines Players (oder mehrerer) mit einem HQL-Query bekomme ich eine Exception geworfen.
Dann will ich mich mal an Eure Vorgaben hier halten :) :
Code between sessionFactory.openSession() and session.close():

Code:
Player p = null;
Query q = session.createQuery("select p from Player p WHERE p.id "+id);
p = (Player)q.uniqueResult();
   if (p != null){
      session.delete(p);
   }
   else{
      System.out.println("Player mit der ID: "+id+" existiert nicht");
   }


Wenn id nicht in der Datenbank existiert, passiert nichts (also das was passieren soll) und wenn sie existiert, wird in der dritten Zeile eine Exception geworfen:

org.hibernate.HibernateException: CGLIB Enhancement failed: oracleTest.wm.Team
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxy(CGLIBLazyInitializer.java:96)
at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.getProxy(CGLIBProxyFactory.java:49)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:379)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3460)
at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:257)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:191)
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:120)
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.doList(Loader.java:2213)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:811)
at oracleTest.wm.Main.deletePlayer(Main.java:88)
at oracleTest.wm.Main.main(Main.java:117)
Caused by: java.lang.InstantiationException: oracleTest.wm.Team$$EnhancerByCGLIB$$e78ba657
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyInstance(CGLIBLazyInitializer.java:107)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxy(CGLIBLazyInitializer.java:93)
... 25 more

Er scheint beim Laden Team in Player nicht instanzieren zu können, aber ich weiß nicht warum.
Der umgekehrte Weg funktioniert. wenn ich ein Team lade, dann hat er auch die zugehörigen Player.

Ich hoffe, dass man mir hier helfen kann!

Gruß, Gilbert

-----------------------------------------------------------------

Hibernate version:
3.2
Name and version of the database you are using:
Oracle 10g


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 07, 2008 5:19 am 
Newbie

Joined: Thu Jul 03, 2008 9:19 am
Posts: 2
es hat wohl daran gelegen, dass ich in Team keinen öffentlichen Default-Konstruktor hatte...


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.