-->
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: Hibernate and oracle views
PostPosted: Wed Feb 15, 2006 5:26 am 
Newbie

Joined: Tue Feb 14, 2006 2:58 pm
Posts: 7
Hi All,

I need to map an oracle view to a class and this using Hibernate, but
I am not succeeding to get it.

It returns some DTD validation problems.

Is anyone knows how to map a view using hibernate.

Thanks in advance for your replies.

Mouad


Top
 Profile  
 
 Post subject: Re: Hibernate and oracle views
PostPosted: Wed Feb 15, 2006 6:41 am 
Beginner
Beginner

Joined: Mon Jan 30, 2006 2:28 am
Posts: 47
Location: INDIA
mouadbox wrote:
Hi All,

I need to map an oracle view to a class and this using Hibernate, but
I am not succeeding to get it.

It returns some DTD validation problems.

Is anyone knows how to map a view using hibernate.

Thanks in advance for your replies.

Mouad


Could U Post Your question in detailed text?

_________________
A.Edward Durai
"The things which are impossible with men are possible with God."


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 15, 2006 6:59 am 
Newbie

Joined: Tue Feb 14, 2006 2:58 pm
Posts: 7
I want to do is to map an oracle view (PERSON_ACCOUNT_VIEW) with hibernate in order to do some selections request from the same view.

But hibernate returns that id or composite-id is a must for the mapping.

so i create an id field in the (PersonAccountObj.java) and set the hibernate mapping

...
<cache usage="read-only"/>
<id name="id" unsaved-value="null">
<generator class="assigned" />
</id>
...

Now hibernate accept this mapping but there is no selection done.

The new error is PERSON_ACCOUNT_VIEW is not mapped, so hibernate cannot perform selections on this view.

Did i misse something to configure ?

thank for the reply.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 15, 2006 8:56 am 
Newbie

Joined: Tue Feb 14, 2006 2:58 pm
Posts: 7
Hi there,

any help will appreciated, I got this :

public static String getimsi = "select x.customerId, x.coId, x.msisdn, x.imsi from BscsContract as x where x.msisdn = ?";
.
.
.
public BscsContract execute(String msisdn) throws BusinessException,
Throwable {
BscsContract activ = null;
Session session = HibernateUtil.currentSession();
Query query = session.createQuery(getimsi);
query.setParameter(0, msisdn);

List<BscsContract> pocs = query.list();
if (pocs.size() < 1) {
log.warn("Carte SIM inexistante pour le msisdn : " + msisdn);
} else {
activ = (BscsContract) pocs.get(0);
}
HibernateUtil.closeSession();
return activ;
}

In the red ligne, I got a ClassCastException.
The thing is that I am selecting from a view so i have added an id field in the BscsContract class.

Would this be the exception source ?

And one more thing I am using JDK 1.5.0, and list with generic type.

Does it have any impact on the way hibernate cast classes ?

Thank in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 15, 2006 9:22 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you are performing a projection query resulting in each row being an Object[] with scalar values for each position.

Object[] o = (Object[]) pocs.get(0);

will work

_________________
Max
Don't forget to rate


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.