-->
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.  [ 4 posts ] 
Author Message
 Post subject: ids for this class must be manually assigned
PostPosted: Thu Oct 04, 2007 3:36 pm 
Beginner
Beginner

Joined: Tue Jul 03, 2007 11:11 am
Posts: 22
Hi all
I get this exception when persisting very simple object:

Code:
org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save


The ID is auto_increment and mapped as Integer.
The DB is MySql v 5.0.41 running on winxp pro.

Any idea?
Thank you
Sharon

Code:
mysql> desc identifier;
+---------------+----------+------+-----+---------+----------------+
| Field         | Type     | Null | Key | Default | Extra          |
+---------------+----------+------+-----+---------+----------------+
| IDENTIFIER_ID | int(11)  | NO   | PRI | NULL    | auto_increment |
| NAME          | char(50) | NO   | UNI |         |                |
+---------------+----------+------+-----+---------+----------------+
2 rows in set (0.00 sec)


The entity:
Code:
@Entity
@Table(catalog="db_name", name="identifier")
public class Identifier {

   private Integer identifierId;
   private String name;

   @Basic
   @Column(name = "NAME", nullable = false, length = 50)
   public String getName() {
      return name;
   }

   public void setName(String name) {
      this.name = name;
   }

   @Id   
   @Column(name = "IDENTIFIER_ID", nullable = false, length = 10)
   public Integer getIdentifierId() {
      return identifierId;
   }

   public void setIdentifierId(Integer identifierId) {
      this.identifierId = identifierId;
   }
}


Exception:
Code:

org.apache.cxf.phase.PhaseInterceptorChain doIntercept Interceptor has thrown exception, unwinding now
pache.cxf.interceptor.Fault:

org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.company.db_name.service.beans.persistence.Idier
   at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:85)
   at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:82)
   at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:56)
   at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:56)
   at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
   at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:87)
   at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:206)
   at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:67)
   at org.apache.cxf.transport.servlet.ServletDestination.doMessage(ServletDestination.java:100)
   at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:224)
   at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:137)
   at org.apache.cxf.transport.servlet.CXFServlet.invoke(CXFServlet.java:261)
   at org.apache.cxf.transport.servlet.CXFServlet.doPost(CXFServlet.java:239)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
   at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:852)
   at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:584)
   at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1508)


Top
 Profile  
 
 Post subject: hi this is kumar
PostPosted: Fri Oct 05, 2007 6:08 am 
Newbie

Joined: Thu Aug 30, 2007 1:05 pm
Posts: 7
Location: Bangalore
In hibernate we have facility to generate the ID automatically by hibernate frame work.

u have to do is
In "
Code:
***.hbm.xml
" File u have to set the Tag Id as increment please go through the Hibernate 3.1 reference.....PDF...

_________________
Kumar Phani


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 05, 2007 7:33 am 
Newbie

Joined: Fri Oct 05, 2007 2:14 am
Posts: 3
Location: chennai
do onething:



change your table schema:

1.don't assign auto-increment to the IDENTIFIER_ID field in identifier table.

Like this::

+---------------+----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+----------+------+-----+---------+----------------+
| IDENTIFIER_ID | int(11) | NO | PRI | NULL | |
| NAME | char(50) | NO | UNI | | |



bcoz, hibernate has it own incrementor in the mapping file..


In your mapping file(xxx.hbm.xml) , give <generator class="increment"/> in the <id> tag .


It's work fine...

_________________
Without self-Confidence ,Without Life

Regards,

Vikneswaran.T


Top
 Profile  
 
 Post subject: Solved!
PostPosted: Sat Oct 06, 2007 5:23 pm 
Beginner
Beginner

Joined: Tue Jul 03, 2007 11:11 am
Posts: 22
Its working using this annotation :
Code:
@GeneratedValue(strategy=GenerationType.AUTO)


(with auto_increment on)
db = MySql
Using JPA EntityManager and not Hibernate session

Thank you
Sharon


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