-->
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: How to use Hibernate with DB2 views
PostPosted: Thu Sep 07, 2006 11:43 am 
Newbie

Joined: Wed Jul 05, 2006 2:26 pm
Posts: 5
Hibernate version:
2, but we are moving to 3 very soon

Mapping documents:
Dont have one...xdoclet fails because there is not ID

Code between sessionFactory.openSession() and session.close():
N/A

Full stack trace of any exception that occurs:
[hibernatedoclet] (XDocletMain.start 54 ) <<Class com.bofa.es
m.dataaccess.automation.vo.ActiveGatewayByBuildingVO misses ID property>>
[hibernatedoclet] C:\dev\Projects\Work\BPA1.5\controller\EJBs\dataaccess\build.x
ml:111: XDoclet failed.
[hibernatedoclet] at xdoclet.DocletTask.start(DocletTask.java:471)
[hibernatedoclet] at xjavadoc.ant.XJavadocTask.execute(XJavadocTask.java:1
05)
[hibernatedoclet] at org.apache.tools.ant.UnknownElement.execute(UnknownEl
ement.java:275)
[hibernatedoclet] at org.apache.tools.ant.Task.perform(Task.java:364)
[hibernatedoclet] at org.apache.tools.ant.Target.execute(Target.java:341)
[hibernatedoclet] at org.apache.tools.ant.Target.performTasks(Target.java:
369)
[hibernatedoclet] at org.apache.tools.ant.Project.executeTarget(Project.ja
va:1214)
[hibernatedoclet] at org.apache.tools.ant.Project.executeTargets(Project.j
ava:1062)
[hibernatedoclet] at org.apache.tools.ant.Main.runBuild(Main.java:673)
[hibernatedoclet] at org.apache.tools.ant.Main.startAnt(Main.java:188)
[hibernatedoclet] at org.apache.tools.ant.launch.Launcher.run(Launcher.jav
a:196)
[hibernatedoclet] at org.apache.tools.ant.launch.Launcher.main(Launcher.ja
va:55)
[hibernatedoclet] Caused by: xdoclet.XDocletException: Class com.bofa.esm.dataac
cess.automation.vo.ActiveGatewayByBuildingVO misses ID property
[hibernatedoclet] at xdoclet.modules.hibernate.HibernateTagsHandler.hasCom
positeId_Impl(HibernateTagsHandler.java:668)
[hibernatedoclet] at xdoclet.modules.hibernate.HibernateTagsHandler.ifHasP
rimitiveId(HibernateTagsHandler.java:211)
[hibernatedoclet] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native M
ethod)
[hibernatedoclet] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMet
hodAccessorImpl.java:39)
[hibernatedoclet] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Deleg
atingMethodAccessorImpl.java:25)
[hibernatedoclet] at java.lang.reflect.Method.invoke(Method.java:324)
[hibernatedoclet] at xdoclet.template.TemplateEngine.invoke(TemplateEngine
.java:641)
[hibernatedoclet] at xdoclet.template.TemplateEngine.invokeMethod(Template
Engine.java:567)
[hibernatedoclet] at xdoclet.template.TemplateEngine.invokeBlockMethod(Tem
plateEngine.java:965)
[hibernatedoclet] at xdoclet.template.TemplateEngine.handleBlockTag(Templa
teEngine.java:932)
[hibernatedoclet] at xdoclet.template.TemplateEngine.handleTag(TemplateEng
ine.java:472)
[hibernatedoclet] at xdoclet.template.TemplateEngine.generate(TemplateEngi
ne.java:348)
[hibernatedoclet] at xdoclet.template.TemplateEngine.start(TemplateEngine.
java:415)
[hibernatedoclet] at xdoclet.TemplateSubTask.startEngine(TemplateSubTask.j
ava:562)
[hibernatedoclet] at xdoclet.TemplateSubTask.generateForClass(TemplateSubT
ask.java:779)
[hibernatedoclet] at xdoclet.TemplateSubTask.startProcessPerClass(Template
SubTask.java:679)
[hibernatedoclet] at xdoclet.TemplateSubTask.startProcess(TemplateSubTask.
java:596)
[hibernatedoclet] at xdoclet.XmlSubTask.startProcess(XmlSubTask.java:227)
[hibernatedoclet] at xdoclet.modules.hibernate.HibernateSubTask.execute(Hi
bernateSubTask.java:136)
[hibernatedoclet] at xdoclet.XDocletMain.start(XDocletMain.java:48)
[hibernatedoclet] at xdoclet.DocletTask.start(DocletTask.java:468)
[hibernatedoclet] ... 11 more
[hibernatedoclet] --- Nested Exception ---
[hibernatedoclet] xdoclet.XDocletException: Class com.bofa.esm.dataaccess.automa
tion.vo.ActiveGatewayByBuildingVO misses ID property
[hibernatedoclet] at xdoclet.modules.hibernate.HibernateTagsHandler.hasCom
positeId_Impl(HibernateTagsHandler.java:668)
[hibernatedoclet] at xdoclet.modules.hibernate.HibernateTagsHandler.ifHasP
rimitiveId(HibernateTagsHandler.java:211)
[hibernatedoclet] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native M
ethod)
[hibernatedoclet] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMet
hodAccessorImpl.java:39)
[hibernatedoclet] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Deleg
atingMethodAccessorImpl.java:25)
[hibernatedoclet] at java.lang.reflect.Method.invoke(Method.java:324)
[hibernatedoclet] at xdoclet.template.TemplateEngine.invoke(TemplateEngine
.java:641)
[hibernatedoclet] at xdoclet.template.TemplateEngine.invokeMethod(Template
Engine.java:567)
[hibernatedoclet] at xdoclet.template.TemplateEngine.invokeBlockMethod(Tem
plateEngine.java:965)
[hibernatedoclet] at xdoclet.template.TemplateEngine.handleBlockTag(Templa
teEngine.java:932)
[hibernatedoclet] at xdoclet.template.TemplateEngine.handleTag(TemplateEng
ine.java:472)
[hibernatedoclet] at xdoclet.template.TemplateEngine.generate(TemplateEngi
ne.java:348)
[hibernatedoclet] at xdoclet.template.TemplateEngine.start(TemplateEngine.
java:415)
[hibernatedoclet] at xdoclet.TemplateSubTask.startEngine(TemplateSubTask.j
ava:562)
[hibernatedoclet] at xdoclet.TemplateSubTask.generateForClass(TemplateSubT
ask.java:779)
[hibernatedoclet] at xdoclet.TemplateSubTask.startProcessPerClass(Template
SubTask.java:679)
[hibernatedoclet] at xdoclet.TemplateSubTask.startProcess(TemplateSubTask.
java:596)
[hibernatedoclet] at xdoclet.XmlSubTask.startProcess(XmlSubTask.java:227)
[hibernatedoclet] at xdoclet.modules.hibernate.HibernateSubTask.execute(Hi
bernateSubTask.java:136)
[hibernatedoclet] at xdoclet.XDocletMain.start(XDocletMain.java:48)
[hibernatedoclet] at xdoclet.DocletTask.start(DocletTask.java:468)
[hibernatedoclet] at xjavadoc.ant.XJavadocTask.execute(XJavadocTask.java:1
05)
[hibernatedoclet] at org.apache.tools.ant.UnknownElement.execute(UnknownEl
ement.java:275)
[hibernatedoclet] at org.apache.tools.ant.Task.perform(Task.java:364)
[hibernatedoclet] at org.apache.tools.ant.Target.execute(Target.java:341)
[hibernatedoclet] at org.apache.tools.ant.Target.performTasks(Target.java:
369)
[hibernatedoclet] at org.apache.tools.ant.Project.executeTarget(Project.ja
va:1214)
[hibernatedoclet] at org.apache.tools.ant.Project.executeTargets(Project.j
ava:1062)
[hibernatedoclet] at org.apache.tools.ant.Main.runBuild(Main.java:673)
[hibernatedoclet] at org.apache.tools.ant.Main.startAnt(Main.java:188)
[hibernatedoclet] at org.apache.tools.ant.launch.Launcher.run(Launcher.jav
a:196)
[hibernatedoclet] at org.apache.tools.ant.launch.Launcher.main(Launcher.ja
va:55)

Name and version of the database you are using:
DB2, some version 8.???

The generated SQL (show_sql=true):
N/A, but here is the create for the view:
CREATE VIEW ACTIVE_GW_BY_BLDG AS SELECT A.GW_NAME,A.BUILDING,
A.EP_TYPE,B.SUBNET, B.RANGE_LOWER,B.RANGE_UPPER
FROM INV4.BLDG_TO_GATE A, INV4.SUB_TO_BLDG B, INV4.GW_INFO C
WHERE A.BUILDING = B.BUILDING AND A.GW_NAME = C.GW_NAME
AND C.GW_ACTIVE = 1;

Debug level Hibernate log excerpt:
N/A




Anyone know how to get Hibernate to work with DB2 views? It fails to build in XDoclet because there is no ID, but views dont have PKs so hence no ID.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 08, 2006 9:35 am 
Regular
Regular

Joined: Fri May 12, 2006 4:05 am
Posts: 106
Hi,

sure, DB2-views may not need a primary key, but nevertheless hibernate needs to have an id-attribute, because you won't be able to find your objects once you stored them to the DB (you won't even be able to tell if you have to save or update them). By the way, hibernate's id-attribute doesn't have to be a primary key, any unique field or combination of fields will do.

Greets

piet


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.