-->
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.  [ 5 posts ] 
Author Message
 Post subject: error with mapping
PostPosted: Wed Sep 17, 2008 10:17 am 
Beginner
Beginner

Joined: Mon Mar 17, 2008 11:25 am
Posts: 42
hi,
I have problem with mapping. I recive fallowing error :
Code:
Exception in thread "main" java.lang.ClassCastException: org.hibernate.impl.QueryImpl cannot be cast to javax.management.Query
   at de.elaser.handwerk2008.DAO.BelegposDAO.get(BelegposDAO.java:20)
   at Main.main(Main.java:10)


here are my classes and mappin files:

Code:

import org.hsqldb.types.Binary;

public class Belegpos {

   
   
   private int id;
   private String belegid;
   private int zeile;
   private String oz;
   private String postyp;
   private String wg;
   private String artnr;
   private float menge;
   private String kurz;
   private Binary lang;
   private float epreis;
   private float vpreis;
   private int steuer;
   private String me;
   private int pe;
   private int rabattpos;
   
   
   Belegpos(){}


   public int getId() {
      return id;
   }


   public void setId(int id) {
      this.id = id;
   }


   public String getBelegid() {
      return belegid;
   }


   public void setBelegid(String belegid) {
      this.belegid = belegid;
   }


   public int getZeile() {
      return zeile;
   }


   public void setZeile(int zeile) {
      this.zeile = zeile;
   }


   public String getOz() {
      return oz;
   }


   public void setOz(String oz) {
      this.oz = oz;
   }


   public String getPostyp() {
      return postyp;
   }


   public void setPostyp(String postyp) {
      this.postyp = postyp;
   }


   public String getWg() {
      return wg;
   }


   public void setWg(String wg) {
      this.wg = wg;
   }


   public String getArtnr() {
      return artnr;
   }


   public void setArtnr(String artnr) {
      this.artnr = artnr;
   }


   public float getMenge() {
      return menge;
   }


   public void setMenge(float menge) {
      this.menge = menge;
   }


   public String getKurz() {
      return kurz;
   }


   public void setKurz(String kurz) {
      this.kurz = kurz;
   }


   public Binary getLang() {
      return lang;
   }


   public void setLang(Binary lang) {
      this.lang = lang;
   }


   public float getEpreis() {
      return epreis;
   }


   public void setEpreis(float epreis) {
      this.epreis = epreis;
   }


   public float getVpreis() {
      return vpreis;
   }


   public void setVpreis(float vpreis) {
      this.vpreis = vpreis;
   }


   public int getSteuer() {
      return steuer;
   }


   public void setSteuer(int steuer) {
      this.steuer = steuer;
   }


   public String getMe() {
      return me;
   }


   public void setMe(String me) {
      this.me = me;
   }


   public int getPe() {
      return pe;
   }


   public void setPe(int pe) {
      this.pe = pe;
   }


   public int getRabattpos() {
      return rabattpos;
   }


   public void setRabattpos(int rabattpos) {
      this.rabattpos = rabattpos;
   }

}

package de.elaser.handwerk2008.DAO;
import javax.management.Query;

import org.hibernate.HibernateException;

import de.elaser.handwerk.HWException.HWException;
import de.elaser.handwerk2008.model.Belegpos;;


public class BelegposDAO extends DAO{

   public BelegposDAO(){}
   
   public Belegpos get()
   
      throws HWException{
      
      try{
         begin();
         Query q=(Query) getSession().createQuery("from Belegpos ");
         //((org.hibernate.Query) q).setString("belegid", belegID);
         Belegpos belpos=(Belegpos)((org.hibernate.Query) q).uniqueResult();
         commit();
         return belpos;
      }
      
      
      catch(HibernateException e){
         rollback();
         throw new HWException("no result",e);
      }
      
   }
   
}

<?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="de.elaser.handwerk2008.model">
   <class
      name="Belegpos"
      table="belegpos"
   >
      <meta attribute="sync-DAO">false</meta>
      <id
         name="id"
         type="integer"
         column="id"
      >
         <generator class="native"/>
      </id>

      <property
         name="belegid"
         column="belegid"
         type="string"
         not-null="true"
         length="8"
      />
      <property
         name="zeile"
         column="zeile"
         type="integer"
         not-null="true"
         length="10"
      />
      <property
         name="oz"
         column="oz"
         type="string"
         not-null="false"
         length="15"
      />
      <property
         name="postyp"
         column="postyp"
         type="string"
         not-null="false"
         length="3"
      />
      <property
         name="wg"
         column="wg"
         type="string"
         not-null="false"
         length="3"
      />
      <property
         name="artnr"
         column="artnr"
         type="string"
         not-null="false"
         length="25"
      />
      <property
         name="menge"
         column="menge"
         type="java.lang.Float"
         not-null="false"
         length="12"
      />
      <property
         name="kurz"
         column="kurz"
         type="string"
         not-null="false"
         length="255"
      />
      <property
         name="lang"
         column="lang"
         type="binary"
         not-null="false"
      />
      <property
         name="epreis"
         column="epreis"
         type="java.lang.Float"
         not-null="false"
         length="12"
      />
      <property
         name="vpreis"
         column="vpreis"
         type="java.lang.Float"
         not-null="false"
         length="12"
      />
      <property
         name="steuer"
         column="steuer"
         type="integer"
         not-null="false"
         length="10"
      />
      <property
         name="me"
         column="me"
         type="string"
         not-null="false"
         length="6"
      />
      <property
         name="pe"
         column="pe"
         type="integer"
         not-null="false"
         length="10"
      />
      <property
         name="rabattpos"
         column="rabattpos"
         type="integer"
         not-null="false"
         length="10"
      />


   </class>   
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
    PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
    <session-factory >

      <!-- local connection properties -->
      <property name="hibernate.connection.url">jdbc:mysql://test-server/Elaser</property>
      <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
      <property name="hibernate.connection.username"></property>
      <property name="hibernate.connection.password"></property>
      <!-- property name="hibernate.connection.pool_size"></property -->

      <!-- dialect for MySQL -->
        <property name="dialect">org.hibernate.dialect.MySQLDialect</property>

        <property name="hibernate.show_sql">false</property>
        <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
      <mapping resource="de\elaser\handwerk2008\model\Belegpos.hbm.xml"/>   
    </session-factory>
</hibernate-configuration>


thanks for your help!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 17, 2008 10:28 am 
Beginner
Beginner

Joined: Mon Mar 17, 2008 11:25 am
Posts: 42
when I change Querry to from belegpos I recive :
Code:
belegpos is not mapped [from belegpos ]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 17, 2008 1:49 pm 
Regular
Regular

Joined: Mon Apr 19, 2004 6:54 pm
Posts: 79
class names are case sensitive.
Code:
from Belegpos


Christophe


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 17, 2008 1:55 pm 
Beginner
Beginner

Joined: Mon Mar 17, 2008 11:25 am
Posts: 42
thanks Christophe i will try it tommorrow .


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 17, 2008 3:25 pm 
Pro
Pro

Joined: Tue Jun 12, 2007 4:13 am
Posts: 209
Location: Berlin, Germany
Have a look at what classes you are importing - the Query class your are using is totally wrong (and read the stacktraces carefully-:) ):

Quote:
import javax.management.Query;


was surely meant to be the JPA interface
Quote:
javax.persistence.Query


the stacktrace says it clearly:
Quote:
Exception in thread "main" java.lang.ClassCastException: org.hibernate.impl.QueryImpl cannot be cast to javax.management.Query

_________________
Carlo
-----------------------------------------------------------
please don't forget to rate if this post helped you


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.