-->
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: Do I need a mapping file?
PostPosted: Fri Oct 15, 2010 5:44 am 
Newbie

Joined: Fri Oct 15, 2010 5:27 am
Posts: 2
Hello,

I am new to Hibernate and need to get something up and running quickly for a test I am doing. I am getting this error:
javax.ejb.EJBException: java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: product is not mapped [FROM product p]

So I started looking around for "hibernate mapping" and took a look at the hibernate tutorial from here: http://docs.jboss.org/hibernate/stable/ ... ml_single/

The entity class it uses looks nothing like mine. I based mine on one I found on the internet, and it looks like this:
Code:
package htest.pdtest;

import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="product")
public class Product implements Serializable
{
   private static final long serialVersionUID = 1L;
   private Long   m_id = -1L;
   private String   m_name;
   
   public Product() {
      super();
   }
   public Product(String name) {
      super();
      m_name = name;
   }
   
   @Id
   @GeneratedValue(strategy=GenerationType.AUTO)
   public Long getId() {
      return m_id;
   }
   public void setId(Long id) {
      m_id = id;
   }
   public String getName() {
      return m_name;
   }
   public void setName(String name) {
      m_name = name;
   }
}


The one in the Hibernate tutorial has none of the annotations, but does use a mapping file. Is it the case that you either have annotations or you use a mapping file?

Thanks,
Paul


Top
 Profile  
 
 Post subject: Re: Do I need a mapping file?
PostPosted: Fri Oct 15, 2010 12:17 pm 
Newbie

Joined: Fri Oct 15, 2010 5:27 am
Posts: 2
My query should have been "FROM Product p" and not "FROM product p".

The reason I posted to the Hibernate forum was that hibernate classes were appearing on the stacktrace, but I didn't even know I was using Hibernate. I have done nothing explicit to do so. I just have a Session Bean and an Entity Bean deployed in JBoss AS 5. This is the first time I have used version 5 of JBoss, and it looks like it now uses Hibernate under the hood. I am used to JBoss 4.0.4 and EJB2.1. Seems things have changed quite a bit!


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.