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.  [ 1 post ] 
Author Message
 Post subject: Strange Hibernate database access
PostPosted: Wed Aug 30, 2006 5:09 am 
Newbie

Joined: Tue Aug 29, 2006 10:52 am
Posts: 1
Location: Reading, Berkshire, UK
We have an application in which we are using Hibernate to look up entries in an Oracle database
Hibernate is version 3.1.1, Oracle is Oracle Database 10g Express Edition Release 10.2.0.1.0
We use JBoss_4.0.3.SP1 as the application server

We are attempting to access the EditorialList table using the following DAO code:

public EditorialList[] findListsByCid(long cid) throws PersistenceException
{
Session s = getSession();
Criteria crit = s.createCriteria(EditorialList.class);
List list = crit.add(Restrictions.eq("cid", cid)).list();
...

The mapping file for EditorialList is

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


<hibernate-mapping package="com.logicacmg.musicportal.frontend.editorial">
<class name="EditorialList" table="editoriallist">
<id name="id" type="long" column="id">
<generator class="seqhilo">
<param name="sequence">SEQ_EditorialList</param>
<param name="max_lo">0</param>
</generator>
</id>
<property name="originaldate" type="timestamp" column="originaldate"/>
<property name="title" type="string" column="title"/>
<property name="cid" type="long" column="cid"/>
<property name="listName" type="string" column="listname"/>
<property name="genre" type="string" column="genre"/>
<property name="listType" type="string" column="listtype"/>
<property name="affiliateId" type="long" column="affiliateid"/>
<property name="subtitle" type="string" column="subtitle"/>
<property name="lastmodified" type="timestamp" column="lastmodified"/>
</class>
</hibernate-mapping>

But it looks like Hibernate is making two accesses when we only expect it to access one
- here is the JBoss log output:

09:33:15,938 INFO [GetAllEditorialListsAction] entering abstractAdminAction
09:33:15,938 INFO [GetAllEditorialListsAction] Checking user with roles PORTALADMIN, matches allowed roles portaladmin
,
09:33:15,938 INFO [GetAllEditorialListsAction] User role PORTALADMIN matched allowed role portaladmin
09:33:15,954 INFO [STDOUT] Could not retrieve datasource using jndi. Try to get local database connection configuration

09:33:15,970 INFO [STDOUT] Hibernate: select this_.id as id38_0_, this_.originaldate as original2_38_0_, this_.title as title38_0_, this_.cid as cid38_0_, this_.listname as listname38_0_, this_.genre as genre38_0_, this_.listtype as listty pe38_0_, this_.affiliateid as affiliat8_38_0_, this_.subtitle as subtitle38_0_, this_.lastmodified as lastmod10_38_0_ from publishededitoriallist this_ where this_.cid=?
09:33:16,016 INFO [STDOUT] Hibernate: select this_.id as id5_0_, this_.originaldate as original2_5_0_, this_.title as title5_0_, this_.cid as cid5_0_, this_.listname as listname5_0_, this_.genre as genre5_0_, this_.listtype as listtype5_0_, this_.affiliateid as affiliat8_5_0_, this_.subtitle as subtitle5_0_, this_.lastmodified as lastmod10_5_0_ from editoriallist this_ where this_.cid=?

Hibernate accesses both a view and a table:
publishededitoriallist - this is a view, of which one component is editoriallist
editoriallist - this is a table
- but we only expect and want it to access editoriallist

Changing the DAO code to

public EditorialList[] findListsByCid(long cid) throws PersistenceException
Session s = getSession();

String sql = "select * from EDITORIALLIST list where cid = " + cid;
List list = s.createSQLQuery(sql)
.addEntity("list", EditorialList.class)
.list();
...

causes Hibernate to just access the editoriallist table as expected


Given that we are very new to Hibernate, this is almost certainly not a Hibernate problem, but the way we are using Hibernate
At this stage we don't know where to look for the problem
- and we may not have provided enough information for anyone to help us

So if anyone can provide us with some help or more information is needed, then please post a reply

Thanks in advance

Geoff Hartnell


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.