• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

hibernate migration

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am migrating my application from hibernate 2.0 to hibernate 3.0 .

I have changed my hibernate.cfg.xml XML DTD to hibernate 3.0

I have changed my hibernate.hbm.xml XML DTD to hibernate 3.0

I have changed my hibernate java classes from net.sf.hibernate into org.hibernate and when i
execute i am getting this error...

Here is my hibernate.hbm.xml file.. Name(Hotlink.hbm.xml)

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-cascade="none">
<class name="com.wamu.dashboard.hotlinks.HotLink" table="HOT_LINK">
<id name="hotLinkId" type="integer" unsaved-value="null" >
<column name="HOT_LINK_ID" sql-type="integer" not-null="true"/>
<generator class="sequence">
<param name="sequence">HOT_LINK_SEQ</param>
</generator>
</id>
<property name="displayName">
<column name="DISPLAY_NAME" sql-type="varchar(60)" />
</property>
<property name="userPermissionCode">
<column name="USER_PERMISSION_CODE" sql-type="varchar(20)" />
</property>
<property name="link">
<column name="LINK" sql-type="varchar(60)" not-null="true"/>
</property>
</class>
<query name="getHotLinksByPermissionCode"><![CDATA[select link, userTargetedContent.displayName from HotLink link, UserTargetedContent userTargetedContent where link.userPermissionCode = userTargetedContent.userPermissionCode and link.userPermissionCode in (:userPermissionCode) order by link.userPermissionCode, link.displayName]]></query>
</hibernate-mapping>

My hibernate.cfg.xml file is given below..

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">weblogic.jdbc.jts.WAMUPool</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
<!-- <property name="show_sql">true</property> -->
<mapping resource="/com/wamu/dashboard/hotlinks/HotLink.hbm.xml"/>
<mapping resource="/com/wamu/dashboard/security/permission/Permission.hbm.xml"/>
<mapping resource="/com/wamu/dashboard/security/permission/UserTargetedContent.hbm.xml"/>
</session-factory>
</hibernate-configuration>

I have used both org.hibernate.hql.classic.ClassicQueryTranslatorFactory and org.hibernate.hql.ast.ASTQueryTranslatorFactory both but, its not working
The error is defined below...


<Jan 8, 2007 10:14:47 PM PST> <Error> <T3Services> <000000> <org.hibernate.impl.SessionFactoryImpl: Error in named query: getHotLinksByPermissionCode

org.hibernate.QueryException: in expected: userTargetedContent [select link, userTargetedContent.displayName from com.wamu.dashboard.hotlinks.HotLink link, UserTargetedContent userTargetedContent where link.userPermissionCode = userTargetedContent.userPermissionCode and link.userPermissionCode in (:userPermissionCode) order by link.userPermissionCode, link.displayName]
at org.hibernate.hql.classic.FromParser.token(FromParser.java:106)
at org.hibernate.hql.classic.ClauseParser.token(ClauseParser.java:86)
at org.hibernate.hql.classic.PreprocessingParser.token(PreprocessingParser.java:108)
at org.hibernate.hql.classic.ParserHelper.parse(ParserHelper.java:29)
at org.hibernate.hql.classic.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:176)
at org.hibernate.hql.classic.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:152)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:425)
at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:386)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:289)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1055)
at com.wamu.dashboard.util.hibernate.HibernateUtil.init(HibernateUtil.java:303)
at com.wamu.dashboard.util.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:75)
at com.wamu.dashboard.util.hibernate.HibernateCommandExecutor.getSession(HibernateCommandExecutor.java:76)
at com.wamu.dashboard.util.hibernate.HibernateCommand.this(HibernateCommand.java:26)
at com.wamu.dashboard.util.hibernate.HibernateCommand.<init>(HibernateCommand.java:31)
at com.wamu.dashboard.security.permission.GetUserTargetedContentCommand.<init>(GetUserTargetedContentCommand.java:30)
at com.wamu.dashboard.security.permission.web.GetUserTargetedContentServlet.myService(GetUserTargetedContentServlet.java:49)
at com.wamu.dashboard.util.web.BaseServlet.service(BaseServlet.java:154)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:996)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:626)
at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:412)
at jsp_servlet._admin._hotlinks.__index._jspService(__index.java:276)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:996)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:463)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6456)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3661)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2630)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)

Help me as soon as possible..

Please help me.. Thanks in advance..
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Renga.

Underneath the Add Reply button are a set of buttons to make some portions of posts look cleaner. Like the CODE button. This will put CODE tags in your post, where you can post code, or other formatted text that you want to keep the indentation. Like an XML file. Not using these and having XML look lik ehow it is posted is really tough to read, at least for me.

Mark
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where is your UserTargetedContent mapping xml. Please post that. I see that your query is using the old fashion WHERE clause theta-style join. If you have a foreign key in the UserTargetedContent to the HotLink, or the other way around, I would probably use that as a FROM clause JOIN.

Also, why do you have to define a hibernate.query.factory_class property at all?

Mark
 
renga ram
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark here is my UserTargetedContent.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-cascade="none">
<class name="com.wamu.dashboard.security.permission.UserTargetedContent" table="USER_TARGETED_CONTENT">
<id name="userTargetedContentId" type="integer" unsaved-value="null" >
<column name="USER_TARGETED_CONTENT_ID" sql-type="integer" not-null="true"/>
<generator class="sequence">
<param name="sequence">USER_TARGETED_CONTENT_SEQ</param>
</generator>
</id>
<property name="contentType">
<column name="CONTENT_TYPE" sql-type="varchar(20)" />
</property>
<property name="displayName">
<column name="DISPLAY_NAME" sql-type="varchar(40)" />
</property>
<property name="targetedContentDescription">
<column name="TARGETED_CONTENT_DESCRIPTION" sql-type="varchar(100)" />
</property>
<property name="userPermissionCode">
<column name="USER_PERMISSION_CODE" sql-type="varchar(20)" />
</property>
</class>
</hibernate-mapping>

please help me to solve this problem..
 
renga ram
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please help me.. Its urgently needed.. I am trying this for the past 4 days..

Thanks in advance..
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I still have my question of

"Also, why do you have to define a hibernate.query.factory_class property at all?"

And why are you using "sql-type" instead of just "type"

Also, I really think that in order to do that query you need to make it an sql-query instead of HQL, mostly because those two objects don't have references to each other, and so how does Hibernate know what type of Object to create when running that query. With the SQL query you can run it and it will return an Object[]

Mark
 
If you live in a cold climate and on the grid, incandescent light can use less energy than LED. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic