-->
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.  [ 3 posts ] 
Author Message
 Post subject: How to map to Database Views
PostPosted: Wed Mar 08, 2006 3:46 am 
Newbie

Joined: Mon Jan 02, 2006 1:40 am
Posts: 9
Hi Everybody,

I am trying to map my objects to Database Views instead of tables. And when I use view name at the place of table name in my mapping file, it gives me "Missing Table" error.

Mapping File:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class name="Group" table="Groups">

<id name="name" column="Group">
</id>

<set name="primeCommodities" inverse="true" fetch="join" cascade="all">
<key column="Group" not-null="true"/>
<one-to-many class="PrimeCommodity"/>
</set>

</class>

</hibernate-mapping>

Error Message
failed.org.hibernate.HibernateException: Missing table: Groups
java.lang.ExceptionInInitializerError
at sa.com.futureware.fastwork.fastsecure.persistance.HibernateUtil.<clinit>(HibernateUtil.java:20)
at Main.main(Main.java:22)
Caused by: org.hibernate.HibernateException: Missing table: Groups
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:953)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:299)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1145)

Please help me in this regard.

Thanks and regards,

_________________
Mirza M.


Top
 Profile  
 
 Post subject: Re: How to map to Database Views
PostPosted: Wed Mar 08, 2006 8:22 am 
Regular
Regular

Joined: Tue Mar 07, 2006 11:18 am
Posts: 54
Location: Berlin
Hi,
I used to create mapping to a DB View by using the view name as the table name just like you did.

This approach is supposed to work, are you quite sure that the view does exist or is it in the right schema you configured in your hibernate.cfg.xml?!

simon


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 08, 2006 10:34 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
mapping POJOs to tables is the same as mapping them to views.

If I had to guess, I'd say your view name is actually 'groups' (with a lowercase g) as it is normal convention for db names to be all lowercase

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


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