-->
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: Query Mapping Exception
PostPosted: Thu May 13, 2004 12:23 pm 
Newbie

Joined: Wed Nov 12, 2003 4:57 pm
Posts: 14
Location: New York City
I am using Hibernate 2.1.3 with Oracle 9i

I am getting a net.sf.hibernate.MappingException: No persister for: java.lang.String

Here is the mapping file:
----------------------------

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

<hibernate-mapping>
<class name="com.amg.condenet.ad.domain.AdSuppression" table="AD_SUPPRESSION" mutable="false">
<composite-id>
<key-property name="mbid" column="mbid" type="string" />
<key-property name="placement" column="placement" type="java.lang.string" />
</composite-id>
</class>
</hibernate-mapping>

Here is the code:
-------------------
Query query =
session.createQuery("select count(*) from
com.amg.condenet.ad.domain.AdSuppression adSuppression " +
"WHERE adSuppression.mbid =? AND adSuppression.placement =?");

query.setEntity(0, mbid);
query.setEntity(1, placement);
query.setMaxResults(1);

int count = ((Integer) query.iterate().next()).intValue();

----------------------

The interesting thing is that if I change the query definition to the following and remove the query.setEntity statements, it works fine:

Query query =
session.createQuery("select count(*) from
com.amg.condenet.ad.domain.AdSuppression adSuppression " +
"WHERE adSuppression.mbid = '" + mbid + "' AND
adSuppression.placement = '" + placement + "'");


Any thoughts?


Top
 Profile  
 
 Post subject: One mistake
PostPosted: Thu May 13, 2004 12:26 pm 
Newbie

Joined: Wed Nov 12, 2003 4:57 pm
Posts: 14
Location: New York City
The mapping file has the line:

<key-property name="placement" column="placement" type="java.lang.string" />

That actually reads:

<key-property name="placement" column="placement" type="string" />


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.