• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Not able to get a Session Factory Object

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)

 
reply
    Bookmark Topic Watch Topic
  • New Topic