-->
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.  [ 1 post ] 
Author Message
 Post subject: @ManyToOne mapping into View
PostPosted: Thu Nov 20, 2008 11:29 pm 
Newbie

Joined: Thu Nov 20, 2008 10:59 pm
Posts: 3
Hi!

I have several problems with many-to-one mapping into View.
I declared a new entity bean for this view and mapped into existing model using @JoinColumns, but facing some problems.

SQL statement for creating view...
Code:
CREATE OR REPLACE VIEW DSC_STUDENT_VIEW (PARTYID, EDUINSTID, NRIC_PASSPORT, LAST_NAME, GIVEN_NAMES, TITLE_CODE, GENDER_CODE,
PROGRAMID, INTAKEID, ACAD_INTAKE_ID,
[b]CONSTRAINT STUDENTPK PRIMARY KEY (PARTYID, EDUINSTID, PROGRAMID, INTAKEID) DISABLE NOVALIDATE)
[/b]AS SELECT A.PARTY_ID, C.EDU_INST_ID, ........................


And in the existing model IncidentStudent
Code:
@ManyToOne(fetch=FetchType.LAZY)
   @JoinColumns({
      @JoinColumn(name="STUDENT_PARTY_ID", referencedColumnName="PARTYID"),
      @JoinColumn(name="EDU_INST_ID", referencedColumnName="EDUINSTID"),
      @JoinColumn(name="PROGRAMME_ID", referencedColumnName="PROGRAMID"),
      @JoinColumn(name="INTAKE_ORG", referencedColumnName="INTAKEID")
   })
   public StudentView getStudentView() {
      return studentView;
   }


In the model StudentView (mapping DSC_STUDENT_VIEW)....
Code:
@OneToMany(mappedBy="studentView")
   public Set<IncidentStudent> getIncidentStudents() {
      return incidentStudents;
   }


If i deploy the project, i can see this exception....
Code:
org.hibernate.MappingException: Unable to find column with logical name: EDUINSTID in DSC_STUDENT_VIEW
   at org.hibernate.cfg.Ejb3JoinColumn.checkReferencedColumnsType(Ejb3JoinColumn.java:383)
   at org.hibernate.cfg.BinderHelper.createSyntheticPropertyReference(BinderHelper.java:88)
   at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:63)
.................................................................


Now i am not sure why this exception occurred in second join column because first join column PARTYID passed.

What is the problem in this code?
Pls help me~~~~~~~


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.