-->
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.  [ 6 posts ] 
Author Message
 Post subject: Problem of retrieve parent from child
PostPosted: Wed Dec 29, 2004 3:28 am 
Beginner
Beginner

Joined: Fri Feb 27, 2004 3:49 am
Posts: 25
Hi,

I have two tables(parent & child) link with one-to-many association. In my case, i want to retrieve parent info directly when i get child. Can hibernate do this?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 29, 2004 5:48 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Yes, but you have to read the docs and some tutorials.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 29, 2004 10:20 pm 
Beginner
Beginner

Joined: Fri Feb 27, 2004 3:49 am
Posts: 25
has any relate example or tutorial for reference? please i really need these...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 29, 2004 11:08 pm 
Newbie

Joined: Wed Feb 25, 2004 11:41 pm
Posts: 19
Location: China
tingling wrote:
has any relate example or tutorial for reference? please i really need these...


http://www.hibernate.org/5.html

_________________
who can tell me why?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 30, 2004 11:48 pm 
Beginner
Beginner

Joined: Fri Feb 27, 2004 3:49 am
Posts: 25
I confuse when i try to retrieve parent from child using hibernate. In my case, i using RCP to do interface design and session bean do business logic processing (like save data, retrieve date ...). I got a EJBInvoker as middleman between my user interface and session bean.

If retrieve a parent, anything run properly and i also got the child info automatically. Now i try to retrieve a child from database. Below source code write in a session bean for retrieve a child from database. I using system.out.println to do tracing and system able to display child info and parent info. That mean i already retrieve parent and child from database successfully.

But if found that if i commented System.out.println, i got error and anything display on my interface. If i uncommented it , anything run properly. What actually got wrong? How to solve it? Please help me!!!

Session ses = null;
try{
boolean trace = logger.isTraceEnabled();

ses = ThreadLocalSession.currentSession();
Query query = ses.createQuery(“select c from Child as c”);
List list = query.list();
Iterator ite = list.iterator();
while(ite.hasNext()){
Child c = (Child)ite.next();
//System.out.println(+c.getParent().getName());
}
ses.flush();

return list;
} catch (HibernateException e) {
ctx.setRollbackOnly();
throw new ServiceException("Unable to search sale contract ", e);
}finally{

try {
ThreadLocalSession.closeSession();
} catch (HibernateException e1) {
e1.printStackTrace();
}
}


Error message i got :

java.lang.reflect.InvocationTargetException
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:324)
at my.com.shinyang.ejb.EJBInvoker.invokeRemoteEJB(EJBInvoker.java:79)
at my.com.shinyang.eply.ui.views.ShipmentCatelogTableView.saveSchedule(ShipmentCatelogTableView.java:576)
at my.com.shinyang.eply.ui.views.ShipmentCatelogView.populateScheduleView(ShipmentCatelogView.java:124)
at my.com.shinyang.eply.ui.views.ShipmentCatelogView.access$1(ShipmentCatelogView.java:114)
at my.com.shinyang.eply.ui.views.ShipmentCatelogView$1.run(ShipmentCatelogView.java:48)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:881)
at org.eclipse.ui.actions.RetargetAction.runWithEvent(RetargetAction.java:212)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:915)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:866)
at org.eclipse.jface.action.ActionContributionItem$8.handleEvent(ActionContributionItem.java:824)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2772)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2431)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1377)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1348)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:254)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141)
at my.com.shinyang.ui.MainWindow.run(MainWindow.java:28)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:335)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:273)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:129)
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:324)
at org.eclipse.core.launcher.Main.basicRun(Main.java:183)
at org.eclipse.core.launcher.Main.run(Main.java:644)
at org.eclipse.core.launcher.Main.main(Main.java:628)

Caused by: java.lang.NoClassDefFoundError: net/sf/cglib/proxy/MethodInterceptor
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
at org.eclipse.osgi.framework.internal.defaultadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:298)
at org.eclipse.core.runtime.adaptor.EclipseClassLoader.defineClass(EclipseClassLoader.java:223)
at org.eclipse.osgi.framework.internal.defaultadaptor.DefaultClassLoader.findClassImpl(DefaultClassLoader.java:281)
at org.eclipse.osgi.framework.internal.defaultadaptor.DefaultClassLoader.findClass(DefaultClassLoader.java:172)
at org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader.findLocalClass(AbstractClassLoader.java:220)
at org.eclipse.core.runtime.adaptor.EclipseClassLoader.basicFindLocalClass(EclipseClassLoader.java:135)
at org.eclipse.core.runtime.adaptor.EclipseClassLoader.findLocalClass(EclipseClassLoader.java:59)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findLocalClass(BundleLoader.java:371)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:402)
at org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader.loadClass(AbstractClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at net.sf.hibernate.proxy.SerializableProxy.readResolve(SerializableProxy.java:45)
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:324)
at java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:925)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1655)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at java.util.ArrayList.readObject(ArrayList.java:547)
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:324)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:838)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1746)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at java.rmi.MarshalledObject.get(MarshalledObject.java:135)
at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:136)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:96)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)
at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:100)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
at $Proxy5.getScheduleByQuery(Unknown Source)
... 33 more


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 31, 2004 9:13 am 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
tingling wrote:
Caused by: java.lang.NoClassDefFoundError: net/sf/cglib/proxy/MethodInterceptor
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:537)


Hibernate requires 'cglib', which was not available to your program when you ran it. The docs will show you which libraries you need in order to run Hibernate: http://www.hibernate.org/hib_docs/refer ... dpartylibs


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.