• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to map database views in Hibernate annotation

 
Rajni Chopra
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am using hibernate annotation for my database table mapping and its work fine. The database guys has change couple of tables into views ( those are include many-to-one and many-to-many mapping), i mapped them as table as :


@Entity
@Table(name = "V_REPORT_TYPE")
@Cache (usage=CacheConcurrencyStrategy.READ_ONLY)
public class ReportType implements Serializable {

But its not working and throwing exception :


org.hibernate.exception.SQLGrammarException: could not load an entity: [au.com.cuscal.connect.domain.ReportType#1]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.loadEntity(Loader.java:2041)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:86)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:76)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3293)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:496)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:477)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:285)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1038)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:630)

I have checked all column names and mapping but its not working and working fine with old tables (those now change to views) . This is bit urgent, please let me know how to fix this.

Rajni
 
Rajni Chopra
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please reply hibernate experts - its really urgent
 
Vijitha Kumara
Bartender
Posts: 3953
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please EaseUp.

Discussion on the same topic here. And a little older topic from Hibernate forums here. I think you can adjust the annotations for the XML.
 
Rajni Chopra
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, my problem is solved it was just the spell mistake from database side . Thanks alot
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!