We are using Oracle. I am trying to get data from oracle view.
I tried creating mapping file for a class representing a view, and it didnot allowed me (hibernate.cfg.xml schema -- has class element, which doesnot have any attributes for supporting view, it has one for table).
I tried using plain reflection, plain sql, it still required class to be persistent (class should have hibernate mapping).
Does any one know wether its possible, whats the best way to do it?
Thanks,
Mehul
-
Does hibernate support getting data from Database Views? (8 messages)
- Posted by: Mehul Patel
- Posted on: September 07 2004 16:06 EDT
Threaded Messages (8)
- Does hibernate support getting data from Database Views? by O Sch on September 09 2004 05:53 EDT
- Does hibernate support getting data from Database Views? by Mehul Patel on September 09 2004 14:33 EDT
- Does hibernate support getting data from Database Views? by Gareth Faires on September 15 2004 06:01 EDT
- Re: Does hibernate support getting data from Database Views? by thirupala annam on December 11 2007 01:22 EST
- Got Error by Sivan VelappanPillai on July 05 2007 17:46 EDT
- Got Error by Prince Sewani on February 27 2012 08:59 EST
- Got Error by Prince Sewani on February 27 2012 09:00 EST
- Continue ... by Sivan VelappanPillai on July 05 2007 17:49 EDT
-
Does hibernate support getting data from Database Views?[ Go to top ]
- Posted by: O Sch
- Posted on: September 09 2004 05:53 EDT
- in response to Mehul Patel
Hi, have you already found an answer to this question? As a hibernate newbie I'm currently asking myself the same (for PostgreSQL).
Thanks,
Oliver -
Does hibernate support getting data from Database Views?[ Go to top ]
- Posted by: Mehul Patel
- Posted on: September 09 2004 14:33 EDT
- in response to O Sch
Hi Oliver,
This is a must have feature for an ORM tool, it should atleast support simple
reflection with no mapping required at the minimum.
I have not found the answer. Team here has no clue either :)
Waiting for some one from hibernate team to clarify.
Mehul -
Does hibernate support getting data from Database Views?[ Go to top ]
- Posted by: Gareth Faires
- Posted on: September 15 2004 06:01 EDT
- in response to Mehul Patel
Hi,
Yes you can use hibernate with views.
Just put your view name in the table attribute.
Here's a mapping I've got for one of our views:
<class name="EnterpriseProject" table="VW_ENTERPRISE_PROJECTS">
<cache usage="read-only"/>
<id name="id" column="project_id" type="string" unsaved-value="null">
<generator class="assigned" />
</id>
<property name="title" />
<property name="description" />
<property name="stage" />
<property name="lob" />
<property name="projectManager" column="project_manager_name" />
</class>
Hope this helps,
Gareth -
Re: Does hibernate support getting data from Database Views?[ Go to top ]
- Posted by: thirupala annam
- Posted on: December 11 2007 01:22 EST
- in response to Gareth Faires
Hi,
Yes you can use hibernate with views.
Just put your view name in the table attribute.
Here's a mapping I've got for one of our views:
Hope this helps,
Gareth -
Got Error[ Go to top ]
- Posted by: Sivan VelappanPillai
- Posted on: July 05 2007 17:46 EDT
- in response to Mehul Patel
it's not working. Got error org.hibernate.hql.ast.QuerySyntaxException: [VIEW_NAME] is not mapped. Any idea ? -
Got Error[ Go to top ]
- Posted by: Prince Sewani
- Posted on: February 27 2012 08:59 EST
- in response to Sivan VelappanPillai
You should use the name of the Java class that you're mapping to the database view. If we take a simple example of one entity being mapped to one table. If you have given Entity name as "User" and the POJO name is "UserEntity" then you should query "from UserEntity" else if you say "from User" , you'll get a similar error saying "User is not mapped". Regards Prince -
Got Error[ Go to top ]
- Posted by: Prince Sewani
- Posted on: February 27 2012 09:00 EST
- in response to Sivan VelappanPillai
You should use the name of the Java class that you're mapping to the database view. If we take a simple example of one entity being mapped to one table. If you have given Entity name as "User" and the POJO name is "UserEntity" then you should query "from UserEntity" else if you say "from User" , you'll get a similar error saying "User is not mapped". Regards Prince -
Continue ...[ Go to top ]
- Posted by: Sivan VelappanPillai
- Posted on: July 05 2007 17:49 EDT
- in response to Mehul Patel
My vie wname is vCustomerList Java Code: Query query = session.createQuery ( "from vCustomerList Order By UPPER(CustomerName)" ); Got same error: Query query = session.createQuery ( "Select CustomerName,... from vCustomerList Order By UPPER(CustomerName)" ); Got error: org.hibernate.hql.ast.QuerySyntaxException: vCustomerList is not mapped [from vCustomerList Order By UPPER(CustomerName)]