aspose file tools*
The moose likes Other Application Frameworks and the fly likes problem with hibernate table mapping. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "problem with hibernate table mapping." Watch "problem with hibernate table mapping." New topic
Author

problem with hibernate table mapping.

Naresh Daswani
Greenhorn

Joined: Mar 02, 2006
Posts: 19
Hi All,

I'm using spring with hibernate. The method below is used to fetch the data from oracle database. When executing this method I'm getting error:
*** ERROR: IwfFormsinfoEO is not mapped.
*** ERROR: Invalid path: 'forms.formId'
*** ERROR: Invalid path: 'forms.formDescription'
Invalid Queryorg.hibernate.hql.ast.QuerySyntaxError: IwfFormsinfoEO is not mapped. [Select forms.formId,forms.formDescription from IwfFormsinfoEO forms where forms.formDescription is not null]

public FormsVO[] getSelectNotice() throws BusinessException
{
List codeElements = new ArrayList();
Session session = null;
Transaction tx=null;
try
{
String queryString = "Select forms.formId,forms.formDescription from "+ ConstantsUtil.FORM_TABLE+" forms where forms.formDescription is not null";
session =getSessionFactory().openSession();
Query query = session.createQuery(queryString);
List ls = query.list();
}
catch(Exception e)
{
logger.error("Unknown Exception=" + e);

}
return null;
}

I'm having a constant FORM_TABLE with value 'IwfFormsinfoEO'. and my mapping file is

<hibernate-mapping auto-import="false">
<class name="com.tier.uiConnect.hibernate.IwfFormsinfoEO" table="IWF_FORMSINFO" >

<id name="formId" column="FORM_ID">
<generator class="assigned"> </generator>
</id>

<property name="formDescription" column="FORM_DESCRIPTION" />
<property name="outgoing" column="OUTGOING" />
<property name="recipientType" column="RECIPIENT_TYPE" />
<property name="incoming" column="INCOMING" />
<property name="incomingDocType" column="INCOMING_DOC_TYPE" />
<property name="wiAssignToRoleId" column="WI_ASSIGN_TO_ROLE_ID" />
<property name="daysToCompleteWork" column="DAYS_TO_COMPLETE_WORK" />
<property name="priority" column="PRIORITY" />
<property name="workTypeId" column="WORK_TYPE_ID" />
<property name="thtemplateid" column="THTEMPLATEID" />
<property name="createdBy" column="CREATED_BY" />
<property name="dateCreated" column="DATE_CREATED" />
<property name="modifiedBy" column="MODIFIED_BY" />
<property name="dateModified" column="DATE_MODIFIED" />
</hibernate-mapping>

I'm also having a java class, IwfFormsinfoEO.java which is mapped with the database table via this XML.

Please let me know what mistake I'm doing...Its urgent.
Kindly help.

Naresh Daswani
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10207
    
166

You will have to mention this hbm file in the hibernate.cfg.xml


[My Blog] [JavaRanch Journal]
Naresh Daswani
Greenhorn

Joined: Mar 02, 2006
Posts: 19
Hi,

I don't have any such hibernate.cfg.xml file, I have defined the things in another xml file of spring in following way..

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.generate_statistics">false</prop>
<prop key="hibernate.autocommit">false</prop>
<prop key="hibernate.connection.datasource">jdbc/uim</prop>
</props>
</property>
<property name="mappingDirectoryLocations">
<list>
<value>classpath:com/tier/uiConnect/common/code/persistence/model</value>
<value>classpath:com/tier/uiConnect/hibernate</value>
</list>
</property>
</bean>

All other files are getting mapped...What is the problem with this file I am not getting...plz help..

Naresh Daswani
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10207
    
166

Are you sure that hbm file is present in either of the directories that you mentioned in:




And what do hibernate logs say, when the session factory is being built?
Naresh Daswani
Greenhorn

Joined: Mar 02, 2006
Posts: 19
yes that file is there...and logs are fine...while building the session factory there is no problem..

while starting the server following is logged

[12/4/06 19:26:43:776 IST] 00000035 Configuration I Mapping file: D:\IWFLatest\uiConnect\WebContent\WEB-INF\classes\com\tier\uiConnect\hibernate\IwfFormsinfoEO.hbm.xml

[12/4/06 19:26:43:776 IST] 00000035 HbmBinder I Mapping class: com.tier.uiConnect.hibernate.IwfFormsinfoEO -> IWF_FORMSINFO

this specifies the configuration is fine..

Naresh Daswani
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10207
    
166

Try changing the HQL to:

Naresh Daswani
Greenhorn

Joined: Mar 02, 2006
Posts: 19
Thanks Jaikiran...it worked but please could you tell me the reason behind this code...as it is not feasible for me to write full path of the EO file, I want to put simple name IwfFormsinfoEO only... for that what should I do...

Thanks for your help.

Naresh Daswani
Namrata Maheshwari
Greenhorn

Joined: Dec 07, 2006
Posts: 3
Try giving package name in hbm file

<hibernate-mapping package="com.....">
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with hibernate table mapping.