• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

String ID

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I solved it with a "assigned" generator class
Thanks anyway
 
Cob is sand, clay and sometimes straw. This tiny ad is made of cob:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic