-->
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.  [ 2 posts ] 
Author Message
 Post subject: HQL problem
PostPosted: Tue Mar 13, 2012 11:06 am 
Newbie

Joined: Tue Mar 13, 2012 10:45 am
Posts: 2
Location: Russia, Samara
Hi all,

Confronted with the problem -

Code:
////////////////// GbCapacityEntity class //////////////////
@Entity
@Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.NONE)
@Table(name = "MARKSIST.GB_CAPACITY")
public class GbCapacityEntity {
    @Id
    @Column(name = "ORG_ID")
    private Integer orgId;
...
    @OneToMany(cascade = CascadeType.ALL,fetch=FetchType.LAZY,mappedBy="gbCapacityEntity")
    private List<GbLoadForecast> gbLoadForecast;
    /**
     *
     * @return
     */
    public List<GbLoadForecast> getGbLoadForecast() {
        return gbLoadForecast;
    }
    /**
     *
     * @param gbLoadForecast
     */
    public void setGbLoadForecast(List<GbLoadForecast> gbLoadForecast) {
        this.gbLoadForecast = gbLoadForecast;
    }



////////////////// GbLoadForecast class //////////////////
@Entity
@Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.NONE)
@Table(name = "MARKSIST.GB_LOAD_FORECAST")
public class GbLoadForecast {
    @Id
    @Column(name = "ORG_ID")
    private Integer orgId;
...
    @ManyToOne(cascade = {CascadeType.REFRESH}, fetch = FetchType.LAZY)
    private GbCapacityEntity gbCapacityEntity;
    /**
     * @return
     */
    public GbCapacityEntity getGbCapacityEntity() {
        return gbCapacityEntity;
    }
    /**
     * @param gbLoadForecast
     */
    public void setGbCapacityEntity(GbCapacityEntity gbCapacityEntity) {
        this.gbCapacityEntity = gbCapacityEntity;
    }
...

////////////////// Some query ////////////////// 
...
        String hql = "FROM com.intellex.marksist.hbn.model.GbLoadForecast E " +
                     "WHERE E.orgId = :id1 AND E.cargoGroup = :id2";

        Session session = HibernateUtil.getMarksistSessionFactory().openSession();
        session.beginTransaction();

        Query query = session.createQuery(hql);
        query.setParameter("id1", orgId);
        query.setParameter("id2", gcId);
        List results = query.list();
        session.close();
...



On the instructions query.list(); thrown exception -
[java] 4085 ["http-apr-8080"-exec-10] ERROR org.hibernate.util.JDBCExceptionReporter - ORA-00904: "GBLOADFORE0_"."GBCAPACITYENTITY_ORG_ID": ???????????? ?????????????

Anybody know why? I would be very grateful! : -)


Top
 Profile  
 
 Post subject: Re: HQL problem
PostPosted: Tue Mar 13, 2012 1:19 pm 
Newbie

Joined: Tue Mar 13, 2012 10:45 am
Posts: 2
Location: Russia, Samara
Added @ JoinColumn annotation in the child class, and now it looks like this -

Code:

////////////////// GbLoadForecast class //////////////////
@Entity
@Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.NONE)
@Table(name = "MARKSIST.GB_LOAD_FORECAST")
public class GbLoadForecast {
    @Id
    @Column(name = "ORG_ID")
    private Integer orgId;
...
    @ManyToOne(cascade = {CascadeType.REFRESH}, fetch = FetchType.LAZY)
    @JoinColumn(name = "ORG_ID")
    private GbCapacityEntity gbCapacityEntity;
    /**
     * @return
     */
    public GbCapacityEntity getGbCapacityEntity() {
        return gbCapacityEntity;
    }
    /**
     * @param gbLoadForecast
     */
    public void setGbCapacityEntity(GbCapacityEntity gbCapacityEntity) {
        this.gbCapacityEntity = gbCapacityEntity;
    }
...



But now another exception - Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: com.intellex.marksist.hbn.model.GbLoadForecast column: ORG_ID (should be mapped with insert = "false" update = "false" )

The thing is, i suspect that there are a bunch of the same name of the field-name ORG_ID column is as in Table MARKSIST.GB_LOAD_FORECAST, and in the table MARKSIST.GB_CAPACITY. Or is not it?


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