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: Error mapping Oracle view
PostPosted: Wed Aug 24, 2005 10:02 am 
Newbie

Joined: Mon Apr 11, 2005 3:41 pm
Posts: 5
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hello, I have tried to figure this out on my own and have not been successful. (obviously) I am modelling a view in Oracle. I used middlegen to create the mapping file. I tweaked it a bit. Basically renaming things. I then used hbmtojava to generate the class.

The issue that I am having is I am getting an empty list returned from a finder method (findById), when I know that 1 record should be returned. I am not getting any errors. When I turned on the sql, I notice that I am not getting any sql for the finder method. I thought that was odd. I turned up the logging in hibernate and here is a snippet of what I got. I have bolded the logging from the find method



Hibernate version:

2.1

Mapping documents:

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

<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1

http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->

<class
name="com.knight.model.AnnualCert"
table="EMP_LIST_ANNUAL_CERT"
mutable="false"
>
<meta attribute="implement-equals" inherit="false">true</meta>
<meta attribute="session-method">HibernateUtil.getSession();</meta>

<composite-id>
<key-property
name="empmastid"
column="EMPMASTID"
type="long"
length="5"
>
<meta attribute="finder-method">findById</meta>
</key-property>
<key-property
name="addressLine1"
column="LINE1"
type="java.lang.String"
length="35"
/>
<key-property
name="addressLine2"
column="LINE2"
type="java.lang.String"
length="35"
/>
<key-property
name="city"
column="CITY"
type="java.lang.String"
length="25"
/>
<key-property
name="state"
column="STATE"
type="java.lang.String"
length="40"
/>
<key-property
name="zip"
column="ZIP"
type="java.lang.String"
length="10"
/>
<key-property
name="registered"
column="REGISTERED"
type="java.lang.String"
length="1"
>
<meta attribute="finder-method">findByRegistered</meta>
</key-property>
</composite-id>


<!-- Associations -->
<!-- derived association(s) for compound key -->
<!-- end of derived association(s) -->


</class>
</hibernate-mapping>


Code for finder and code that calls finder

Code:
package com.knight.finder;

import com.knight.exceptions.InfrastructureException;
import com.knight.hibernate.HibernateUtil;
import net.sf.hibernate.Hibernate;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;

import java.io.Serializable;
import java.util.List;

/** Automatically generated Finder class for AnnualCertFinder.
* @author Hibernate FinderGenerator  **/
public class AnnualCertFinder implements Serializable {

    public static List findById(java.lang.Long empmastid) throws InfrastructureException, HibernateException {
        Session session = HibernateUtil.getSession();
        List finds = session.find("from com.knight.model.AnnualCert as annualcert where annualcert.empmastid=?", empmastid, Hibernate.LONG);
        return finds;
    }

    public static List findByRegistered(java.lang.String registered) throws InfrastructureException, HibernateException {
        Session session = HibernateUtil.getSession();
        List finds = session.find("from com.knight.model.AnnualCert as annualcert where annualcert.registered=?", registered, Hibernate.STRING);
        return finds;
    }

    public static List findAll() throws InfrastructureException, HibernateException {
        Session session = HibernateUtil.getSession();
        List finds = session.find("from AnnualCert in class com.knight.model.AnnualCert");
        return finds;
    }

}




jsp code that calls find

Code:
   List annualCerts = AnnualCertFinder.findById(new Long(empId));


Full stack trace of any exception that occurs:

no exception occurring

Name and version of the database you are using:

Oracle 9i

The generated SQL (show_sql=true):

Not generating for this find method

Debug level Hibernate log excerpt:


2005-08-24 09:22:07,749:[com.knight.hibernate.HibernateUtil] : DEBUG - Entered getSession
2005-08-24 09:22:07,749:[net.sf.hibernate.impl.SessionImpl] : DEBUG - find: from com.knight.model.AnnualCert as annualcert where annualcert.empmastid=?
2005-08-24 09:22:07,749:[net.sf.hibernate.engine.QueryParameters] : DEBUG - parameters: [3053]
2005-08-24 09:22:07,749:[net.sf.hibernate.hql.QueryTranslator] : WARN - no persistent classes found for query class: from com.knight.model.AnnualCert as annualcert where annualcert.empmastid=?

2005-08-24 09:22:07,749:[net.sf.hibernate.impl.SessionImpl] : DEBUG - flushing session
2005-08-24 09:22:07,749:[net.sf.hibernate.impl.SessionImpl] : DEBUG - Flushing entities and processing referenced collections
2005-08-24 09:22:07,749:[net.sf.hibernate.impl.SessionImpl] : DEBUG - Collection found: [com.knight.model.Costcenter.employeeMasters#886], was: [com.knight.model.Costcenter.employeeMasters#886]
2005-08-24 09:22:07,749:[net.sf.hibernate.impl.SessionImpl] : DEBUG - Collection found: [com.knight.model.GlAdpCode.employeeMasters#TJX], was: [com.knight.model.GlAdpCode.employeeMasters#TJX]
2005-08-24 09:22:07,749:[net.sf.hibernate.impl.SessionImpl] : DEBUG - Collection found: [com.knight.model.Location.employeeMasters#11], was: [com.knight.model.Location.employeeMasters#11]
2005-08-24 09:22:07,749:[net.sf.hibernate.impl.SessionImpl] : DEBUG - Processing unreferenced collections
2005-08-24 09:22:07,749:[net.sf.hibernate.impl.SessionImpl] : DEBUG - Scheduling collection removes/(re)creates/updates
2005-08-24 09:22:07,749:[net.sf.hibernate.impl.SessionImpl] : DEBUG - Flushed: 0 insertions, 0 updates, 0 deletions to 4 objects
2005-08-24 09:22:07,749:[net.sf.hibernate.impl.SessionImpl] : DEBUG - Flushed: 0 (re)creations, 0 updates, 0 removals to 3 collections
2005-08-24 09:22:07,749:[net.sf.hibernate.impl.Printer] : DEBUG - listing entities:
2005-08-24 09:22:07,749:[net.sf.hibernate.impl.Printer] : DEBUG - com.knight.model.EmployeeExchg{filenum=null, telephone=201-111-1111, msnim=ggershaw@hotmail.com, glAdpCode=GlAdpCode#TJX, userid=ggershaw, txtmsgid=null, aolim=fake, cellphone=null, windowsDomain=KNIGHTCSD.COM, hiredate=27 December 2004, location=Location#11, extension2=null, empmastid=3053, extension=null, password=1f733e9860908104111c17b65534c578, ssn=11111111, lname=Gershaw, yahooim=fake, status=A, benefittier=1, telephone2=null, newEmpEmailSent=true, fname=Geoffrey Adam, costcenter=Costcenter#886, termdate=null, ctitlecode=ASSOC, email=fake@knight.com}
2005-08-24 09:22:07,749:[net.sf.hibernate.impl.Printer] : DEBUG - com.knight.model.Location{effdt=null, locid=25, country=64, employeeMasters=uninitialized, obsolete=null, address=545 Washington Blvd, description=Jersey City - 545, locode=11, state=32}
2005-08-24 09:22:07,749:[net.sf.hibernate.impl.Printer] : DEBUG - com.knight.model.GlAdpCode{adpCode=TJX, employeeMasters=uninitialized, glCode=KEM, summAccountNumber=2201000000000000000}
2005-08-24 09:22:07,749:[net.sf.hibernate.impl.Printer] : DEBUG - com.knight.model.Costcenter{effdt=null, division=12, cctrdesc=Enterprise Systems Development, cctrid=82, type=62, cctrcode=886, employeeMasters=uninitialized, obsolete=null, revenue=null}
2005-08-24 09:22:07,749:[net.sf.hibernate.impl.SessionImpl] : DEBUG - Dont need to execute flush


Top
 Profile  
 
 Post subject: I figured it out
PostPosted: Wed Aug 24, 2005 10:49 am 
Newbie

Joined: Mon Apr 11, 2005 3:41 pm
Posts: 5
I got the answer. I didn't include the name of the mapping file in the hibernate.cfg.xml file.

Strange that no error was thrown.

Oh well


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.