-->
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.  [ 5 posts ] 
Author Message
 Post subject: issue with querying multi join table
PostPosted: Thu Sep 04, 2008 7:08 am 
Newbie

Joined: Thu Sep 04, 2008 6:57 am
Posts: 3
Hi everyone,

I read up a bit about using HQL to query many to one association and try using getHibernateTemplate() from spring to query some stuff. I keep getting nothing from the following code as the items returned is blank.

Code:
String query = "select pa from PayerAccount pa join pa.payee p where pa.agencyAbbreviation='"+agencyAbbreviation+"'";   
        Iterator items = getHibernateTemplate().iterate(query);
        while ( items.hasNext() ) {
              PayerAccounts item = (PayerAccount) items.next();
        }


Basically, i just want to get a list of payer accounts with the desired payee agency. Can someone offer any alternative solution ? I tried a lot of combination of HQL but to no avail. I am not sure if my HQL is created correctly. Appreciate if someone can suggest the correct HQL for the above query. My object definition is as follows:

PayerAccount Object
Code:
@Entity
public class PayerAccount extends BaseObject implements Serializable {
   
    @Id  @GeneratedValue(strategy=GenerationType.AUTO)
    private Long id;
   
    @Column(length=100)
    private String payerAccountNo;
   
    @Column(length=10)
    private String nric;
   
    @Column(length=100)
    private String agencyAbbreviation;
   
    @ManyToOne
    @JoinColumn(name="nric", nullable=false, insertable = false, updatable = false)
    @org.hibernate.annotations.ForeignKey(name = "FK_PAYER_ID")
    private Payer payer;


    @ManyToOne
    @JoinColumn(name = "agencyAbbreviation",  nullable = false,insertable = false, updatable = false)
    @org.hibernate.annotations.ForeignKey(name="FK_PAYEE_ID")
    private Payee payee;
....


Payee Object

Code:
@Entity
public class Payee extends BaseObject implements Serializable{
     @Id  @GeneratedValue(strategy=GenerationType.AUTO)   
      private Long id;
      @Column(nullable=false,length=50,unique=true)
     private String agencyAbbreviation;
 
     @OneToMany(cascade ={CascadeType.ALL}, mappedBy="payee", fetch = FetchType.LAZY)@org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
   private List<PayerAccount> registeredPayerAccounts



Payer Object

Code:
@Entity
public class Payer extends BaseObject implements Serializable{

    ...
    @Column(nullable=false,length=50,unique=true)
    private String nric;

    @OneToMany(cascade ={CascadeType.ALL}, mappedBy="payer", fetch=FetchType.LAZY)
@org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
private List<PayerAccount> registeredPayerAccounts
....



My configuration as follows:
Hibernate ver 3.2.6
MySQL ver 5


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 04, 2008 4:37 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

as far as I can see you would not have to join in your example. Just something like this should do:

Code:
String query = "from PayerAccount pa where pa.agencyAbbreviation='"+agencyAbbreviation+"'";


Unless I misunderstood your usecase.

--Hardy


Top
 Profile  
 
 Post subject: throw object not found exception when using HQL
PostPosted: Thu Sep 04, 2008 10:29 pm 
Newbie

Joined: Thu Sep 04, 2008 6:57 am
Posts: 3
hardy.ferentschik wrote:
Hi,

as far as I can see you would not have to join in your example. Just something like this should do:

String query = "from PayerAccount pa where pa.agencyAbbreviation='"+agencyAbbreviation+"'";


Unless I misunderstood your usecase.

--Hardy


Thanks Hardy. I tried putting in your suggested query. It did return the correct number of records but i hit the following exception when i try to print out the content of the object.

org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.project.app.model.PayerAccount#6]


Code:
String query = "from PayerAccount pa where pa.agencyAbbreviation='"+agencyAbbreviation+"'";
        Iterator<PayerAccount> items = getHibernateTemplate().iterate(query);
        while ( items.hasNext() ) {
            PayerAccount tempPA = items.next();
            log.debug("Account is " + tempPA.getAccountNo());
        }


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 05, 2008 4:47 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

Maybe you could provide the stack trace and also the sql log file. One thing I noticed is that that you are using agencyAbbreviation twice in your PayerAccount object. Once as simple string and once as join column. Why do you do that?

--Hardy


Top
 Profile  
 
 Post subject: issue with querying multi join table
PostPosted: Fri Sep 05, 2008 11:51 pm 
Newbie

Joined: Thu Sep 04, 2008 6:57 am
Posts: 3
The exception trace is as follows:
Code:
javax.servlet.ServletException: javax.servlet.ServletException: org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.myproject.app.model.PayerAccount#6]
   at net.sf.ehcache.constructs.web.filter.Filter.logThrowable(Filter.java:152)
   at net.sf.ehcache.constructs.web.filter.Filter.doFilter(Filter.java:97)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:359)
   at org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
   at org.springframework.security.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
   at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
   at org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101)
   at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
   at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
   at org.springframework.security.providers.anonymous.AnonymousProcessingFilter.doFilterHttp(AnonymousProcessingFilter.java:105)
   at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
   at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
   at org.springframework.security.ui.rememberme.RememberMeProcessingFilter.doFilterHttp(RememberMeProcessingFilter.java:116)
   at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
   at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
   at org.springframework.security.wrapper.SecurityContextHolderAwareRequestFilter.doFilterHttp(SecurityContextHolderAwareRequestFilter.java:91)
   at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
   at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
   at org.springframework.security.ui.basicauth.BasicProcessingFilter.doFilterHttp(BasicProcessingFilter.java:172)
   at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
   at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
   at org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:268)
   at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
   at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
   at org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(LogoutFilter.java:87)
   at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
   at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
   at org.springframework.security.ui.SessionFixationProtectionFilter.doFilterHttp(SessionFixationProtectionFilter.java:61)
   at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
   at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
   at org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)
   at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
   at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
   at org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:174)
   at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
   at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at com.myproject.app.webapp.filter.LocaleFilter.doFilterInternal(LocaleFilter.java:74)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at com.opensymphony.clickstream.ClickstreamFilter.doFilter(ClickstreamFilter.java:42)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
   at java.lang.Thread.run(Thread.java:619)
Caused by: javax.servlet.ServletException: org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.myproject.app.model.PayerAccount#6]
   at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515)
   at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at com.myproject.app.webapp.filter.StaticFilter.doFilterInternal(StaticFilter.java:106)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118)
   at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:164)
   at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:141)
   at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:90)
   at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:406)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at net.sf.ehcache.constructs.web.filter.GzipFilter.doFilter(GzipFilter.java:75)
   at net.sf.ehcache.constructs.web.filter.Filter.doFilter(Filter.java:92)
   ... 64 more
Caused by: org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.myproject.app.model.PayerAccount#6]
   at org.hibernate.impl.SessionFactoryImpl$1.handleEntityNotFound(SessionFactoryImpl.java:377)
   at org.hibernate.proxy.AbstractLazyInitializer.checkTargetState(AbstractLazyInitializer.java:79)
   at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:68)
   at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
   at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150)
   at com.myproject.app.model.PayerAccount$$EnhancerByCGLIB$$75f745df.getPayerAccountNo()
   at com.myproject.app.dao.hibernate.PayerAccountDaoHibernate.findByPayee(PayerAccountDaoHibernate.java:32)
   at com.myproject.app.service.impl.PayerAccountManagerImpl.findByPayee(PayerAccountManagerImpl.java:22)
   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:597)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
   at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
   at $Proxy38.findByPayee(Unknown Source)
   at com.myproject.app.webapp.action.PayerAccountAction.getAgencyPayerAccounts(PayerAccountAction.java:168)
   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:597)
   at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:404)
   at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:267)
   at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:229)
   at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221)
   at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
   at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
   at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
   at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150)
   at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48)
   at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
   at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
   at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
   at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:123)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
   at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
   at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
   at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:167)
   at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
   at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
   at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
   at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:105)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
   at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
   at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
   at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:83)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
   at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
   at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
   at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:207)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
   at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
   at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
   at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:74)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
   at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
   at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
   at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:127)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
   at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
   at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
   at org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:107)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
   at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
   at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
   at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:206)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
   at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
   at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
   at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:115)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
   at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
   at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
   at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:143)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
   at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
   at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
   at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:121)
   at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
   at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
   at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
   at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:170)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
   at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
   at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
   at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:123)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
   at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
   at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
   at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
   at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
   at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
   at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
   at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:50)
   at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:504)
   ... 89 more


The generated SQL as follows:
Code:
DEBUG [http-8081-1] SQL.log(401) | select payee0_.id as id3_, payee0_.agencyAbbreviation as agencyAb2_3_, payee0_.agencyFullName as agencyFu3_3_, payee0_.agencyLogoPath as agencyLo4_3_, payee0_.category as category3_, payee0_.datecreated as datecrea6_3_, payee0_.password as password3_ from Payee payee0_ where payee0_.agencyAbbreviation=?
DEBUG [http-8081-1] SQL.log(401) | select payeraccou0_.id as col_0_0_ from PayerAccount payeraccou0_ where payeraccou0_.agencyAbbreviation='PUB'
DEBUG [http-8081-1] SQL.log(401) | select payeraccou0_.id as id4_2_, payeraccou0_.agencyAbbreviation as agencyAb2_4_2_, payeraccou0_.datecreated as datecrea3_4_2_, payeraccou0_.nric as nric4_2_, payeraccou0_.payerAccountNo as payerAcc5_4_2_, payee1_.id as id3_0_, payee1_.agencyAbbreviation as agencyAb2_3_0_, payee1_.agencyFullName as agencyFu3_3_0_, payee1_.agencyLogoPath as agencyLo4_3_0_, payee1_.category as category3_0_, payee1_.datecreated as datecrea6_3_0_, payee1_.password as password3_0_, payer2_.id as id2_1_, payer2_.address as address2_1_, payer2_.datecreated as datecrea3_2_1_, payer2_.dob as dob2_1_, payer2_.mobilephone as mobileph5_2_1_, payer2_.name as name2_1_, payer2_.nric as nric2_1_, payer2_.password as password2_1_ from PayerAccount payeraccou0_ inner join Payee payee1_ on payeraccou0_.agencyAbbreviation=payee1_.id inner join Payer payer2_ on payeraccou0_.nric=payer2_.id where payeraccou0_.id=?


I have two agencyAbbreviation, the one annotated with @Column(length=100) is to tell hibernate to create a column. The one with the join column is tell hibernate this is the foreign key to the payee table.
I suspect that my understanding of how hibernate uses the annotation to link two table via foreign key is wrong...


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