File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not able to get a Session Factory Object

 
Kamal Bindra
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to join two tables User and Album_Detail where Album_Detail has a foreign key userid and id is PK in User. this ia what i have wrriten in code
@OneToMany(cascade = CascadeType.ALL)
@JoinTable(name = "USER_ALBUMS", joinColumns = { @JoinColumn(table = "USER", name = "ID") }, inverseJoinColumns = { @JoinColumn(table = "ALBUM_DETAIL", name = "ID") })

But i ma getting this exception...please help me to fix the issue.
Any help is highly appreciated in advance and here are the logs..


org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.AnnotationException: Cannot find the expected secondary tabl advancee: no USER available for com.nstudio.itoddler.common.TimeLogPojo
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

root cause

org.hibernate.AnnotationException: Cannot find the expected secondary table: no USER available for com.nstudio.itoddler.common.TimeLogPojo
org.hibernate.cfg.Ejb3Column.getJoin(Ejb3Column.java:293)
org.hibernate.cfg.Ejb3Column.getTable(Ejb3Column.java:272)
org.hibernate.cfg.AnnotationBinder.bindManyToOne(AnnotationBinder.java:1946)
org.hibernate.cfg.AnnotationBinder.bindOneToOne(AnnotationBinder.java:2116)
org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1403)
org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:754)
org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:534)
org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:286)
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
com.nstudio.itoddler.util.HibernateUtil.getSessionFactory(HibernateUtil.java:13)
com.nstudio.itoddler.service.impl.UserBusinessService.addUser(UserBusinessService.java:21)
com.nstudio.itoddler.ws.action.UserServlet.addUser(UserServlet.java:31)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


Thanks,
Kamal Bindra
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK well this is not a Spring issue it is an ORM issue. You would probably get better attention posting this question in the ORM forum..

That said you have not posted enough information to really help you, but I am not sure you need a join table for this. You have a One to many so on the inverse side you will have a many to one. Since I have no idea the context of the application I will give you a different example. Consider an Employee and a Department, where a department has many employees but an employee can only belong to one department. Note the generation strategy was chosen for simplicity it is not usually the best choice.





The ddl for something like this could be like below (shown for Derby)

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic