Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML
 
 
Hot Web Programming Job

 

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML


 

Java Tutorials

Core Java
JSP
Servlet
JDBC
Hibernate
Struts 1
Struts 2
JSF
Spring
J2EE
J2ME
Web Services
Ajax
Dojo
MySQL
Latest Comments
Null pointer excep
swap program faile
hi.........
very good
navigaton mobile
  All Comments...
 

 

 
Struts Tutorials
*Stuts TOC
*Apache Struts Introduction
* Struts Controller
* Struts Action Class
* Struts ActionFrom Class
* Using Struts HTML Tags
*Struts Validator Framework    
*Client Side Address Validation    
*Struts Tiles
*tiles-defs.xml
*Struts DynaActionForm
*Struts File Upload
*Struts DataSource
*AGGREGATING ACTIONS
*Internationalization
Struts Resources
*Struts Books
*Struts Articles
*Struts Frameworks
*Struts IDE
*Struts Alternative
*Struts Links
*Struts Presentations
*Struts Projects
*Struts Software
*Struts Reference
*Struts Resources
*Other Struts Tutorial
Visit Forum! Post Questions!
Jobs At RoseIndia.net!

Have tutorials?
Add your tutorial to our Java Resource and get tons of hits.

We offer free hosting for your tutorials. and exposure for thousands of readers. drop a mail
roseindia_net@yahoo.com
 
   

 
Join For Newsletter

Powered by groups.yahoo.com
Visit Group! Post Questions!

Hibernate Hibernateidgeneratorelement

User Comments
Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl
  Blink   Furl   Simpy   Y! MyWeb 

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

26 comments so far (post your own) View All Comments Latest 10 Comments:

Hi All,
I uesd <generator class="increment"/> in hbm.xml file. I am getting "could not fetch initial value for increment generator" Error. Please help me to solve this problem.

Regards,
Sandeep

Posted by Sandeep on Sunday, 12.7.08 @ 22:21pm | #82489

iam doing a project matrmonial iwant to develop REGISTRATION FORM.PLS HELP ME

Posted by chalamreddy on Monday, 07.28.08 @ 18:44pm | #69565

Hi,

I have an entity object which have an id with sequence generator. in some case i want to override this generator if the id is being passed by entity object. Is it possible to achieve this by <generator class="sequence"> itself?

Please help me on this

Posted by Jeya Uma on Tuesday, 06.10.08 @ 18:50pm | #62897

hi

Posted by Raveendra on Monday, 05.19.08 @ 16:50pm | #60451

hello everybody ...
For the single primary key.not at all a problem. we can work it out. But what to do with composit primary key.i.e. in a table primary key is made up of combination of more than one field.


regards
uday bhat

Posted by uday bhat on Tuesday, 05.6.08 @ 12:01pm | #58608

When i tried with the example given, only tables are created. But data is not inserted ...

I tried like this..

create a transaction object(tx) with the session i.e session.beginTransaction(). and then tx.commit() to commit the transaction. Then my data is updated and inserted in the table.

I think by default autocommit may be false.

Enjoy..
Mythili

Posted by Mythili on Wednesday, 04.30.08 @ 15:36pm | #58212

Hi, I'm trying to generate an id in hibernate in a specific format i.e. i want it to appear 0001,0002, etc ...

Here is the code I use in my request.hbm.xml file

<id name="requestId" column="REQUEST_ID">
<generator class="increment"/>
</id>

but this generates the ids 1,2,etc...

Any idea's?

Posted by Amanda Sweeney on Thursday, 03.6.08 @ 15:39pm | #51693

Hi,
I writtenexaple in that in i mentioned generator class="sequence" but its giving fallowing exaception can any help me to solve that problem.

error like this:
org.hibernate.HibernateException: identifier of an instance of com.Honey altered from 2 to 2

if i use class="genarator" its working fine.

Posted by Ravi Kumar on Monday, 02.4.08 @ 22:26pm | #47214

Hi RoseIndiaTeam,

who is the subject matter expert in maintaining this site for java in RoseIndia? really i want to talk to them once .......

very nice site for Java Developers.

the structure, point wise explianation is really heart touching

keep on updating the site ............




stephen
09818827207

Posted by T.Stephen on Wednesday, 01.30.08 @ 19:17pm | #46617

I am new to Hibernate. I have tried with given example source . All the mapped tables are being created but data is not been inserted in table. Even there is no exception. Can you please guide me what could be possible reason for this??

Posted by Shikhar on Tuesday, 01.29.08 @ 17:25pm | #46497

Hi,

Im new to Hibernate as well as MyEclipse5.1.
When Im reverse engineering the required table in the opened Database connection Im able to create the Dao file xml file and everything but when Im using the HQL editor to access the table it is sayin that the table is not mapped from the table.
can u plz help me out with this

Uma

Posted by uma on Saturday, 12.29.07 @ 17:02pm | #44135

User (password, username) values (?, ?) this problem arises when the mapping is not done properly .I mean that by default generator id will be set to assigned.Insead cahnge that to increment it will get inserted without any error

Posted by shilpa on Monday, 12.24.07 @ 15:09pm | #43573

Nice Document of rose.

Posted by abhishek on Friday, 12.7.07 @ 19:18pm | #41552

hello everybody ...
i am facing very different kind of problem..
i am learning hibernate3 and i am using MS SQL server 2000 as DB manager.
I have created a table User with fields
username PK int
password varchar(50)
i also have created the mapping file and class.
and also my username field is not auto-incremented..

The problem is when i want to add a tuple in User table by using hibernate i got a exception..

Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not insert:
query created by hibernate is look likes as
Hibernate: insert into User (password, username) values (?, ?)
its the right query... but i dont know why it is not inserting value into database...
kindly help me.. i am very tense due to this problem..

Posted by sikander zaman on Saturday, 12.1.07 @ 14:23pm | #41024

I also have the same problem - I am using UUID generator & my set id is overidden. One solution I found was to use a HQL insert statement instead of an object based approach which worked, but I would prefer to use objects - did you find a solution ?

all the best !

Posted by Steve on Thursday, 11.8.07 @ 22:34pm | #36715

Can I create a table dynamically using Hibernate. Like u do it 4 JDBC. Coz as far as I no since u need hbm.xml files n config files for loading Objects(POJOs) in session. Plz help me.

Posted by Bibin on Tuesday, 09.4.07 @ 18:25pm | #25003

Thank for Roseindia, this site is very2 helpful for those who are trying to learn a new techno with the correct / basic step

question : how to map the table if we have 2 or more PK

Tq

Shook

Posted by shukri on Saturday, 08.25.07 @ 10:40am | #24091

If I set the ID value before calling save, my given ID value is overridden by the generator - is there any way around this ? i.e. I want to use my ID in preference to the generator in some instances. thanks !

Posted by Steve on Wednesday, 08.8.07 @ 20:22pm | #22954

I am really ThankFul to roseindia site, having this sort of tutorial.It s really help me out.

Good Work... Team

All The Best.

Posted by Amit on Friday, 05.4.07 @ 16:47pm | #15267

hi i am new to application ,

Posted by kishore on Monday, 04.9.07 @ 17:44pm | #13645

very nice

Posted by sivamurthy on Thursday, 04.5.07 @ 16:58pm | #13394

I Appreciate the guys behind this,cheers for the fantastic work

Posted by Khaja Ameenuddin on Wednesday, 02.7.07 @ 20:26pm | #6644

Hi Danial,

It's because of the SQL Server data type is mismatch with the Java Data type. My Opinion is to change the SQL data type to long in order to over come that error. please try and confirm by return.

Rgds,
Rao

Posted by Rao on Tuesday, 12.19.06 @ 00:53am | #1206

Anyone have any clue on it?

Posted by Daniel on Friday, 12.1.06 @ 15:40pm | #324

I facing some problem on mapping the database column to Hibernate.

The source is:-

<id name="id" type="long">
<column name="uid" sql-type="uniqueidentifier"/>
<generator class="guid"/>
</id>

And the error is:-
ERROR - [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Operand type clash: uniqueidentifier is incompatible with tinyint

The field "uid" in MSSQL is a uniqueidetifier with newid() field. How to map this field to hibernate?

Posted by Daniel on Friday, 12.1.06 @ 13:10pm | #311

Great help. this article explains clearly how to use generator and also lists the generators.Gr8!!!
keep up the good work.
Arv

Posted by arvind on Monday, 11.27.06 @ 19:58pm | #153

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Back to Tutorial

 

  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2007. All rights reserved.