Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String ID

 
Miguel Flecha
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.
I'm trying to insert into a MySQL db using hibernate. The problem is that the primary key is a String, so I get the following exception:

net.sf.hibernate.id.IdentifierGenerationException: this id generator generates long, integer, short

How can I solve this?

Thanks in advance
Regards from Spain
 
Ta Ri Ki Sun
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the mapping for that table if the following doesn't help you.
The bit of interest should look like this

now check that your type is correct and that your generator class is correct.
[ June 23, 2004: Message edited by: Ta Ri Ki Sun ]
 
Miguel Flecha
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<id
column="EMAIL"
length="20"
name="email"
type="string"
>
<generator class="vm" />
</id>

is this correct?
 
Miguel Flecha
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The generator class must be the one from where I call Hibernate??
Do I have to put the complete package? org.struts.....RegistroAction??
Thanks
 
Miguel Flecha
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone help me?? I'm not able to solve this...
 
Ta Ri Ki Sun
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
firstly check your install directory for the following file.
hibernate-2.1/doc/reference/en/html_single/index.html

you can go directly to generator by appending #mapping-declaration-id-generator, assuming you also have 2.1 installed.

here you'll find a list of generators, vm is not one of them, unless its your own implementation which seems unlikely.
anyhat, for strings have a look at uuid.hex, uuid.string and assigned if you'll be setting it.

this should work
 
Miguel Flecha
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I solved it with a "assigned" generator class
Thanks anyway
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic