Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Generated Value Strategy

 
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
I am learning JPA from book Pro JPA 2- and I have a doubt in the topic - ID Generation using the Table
My doubt is regarding @TableGenerator
When I used


it behaved like AUTO strategy.(Did it happen because I missed the strategy? But no such mention in the book :S)

When I gave the table name as below:

it still behaved like AUTO, even though I have the table this time in my database as

+-----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| id_gen | varchar(100) | NO | PRI | | |
| key_value | int(11) | YES | | NULL | |
+-----------+--------------+------+-----+---------+-------+

Please clarify as the behavior is not clear to me.
I came across this while trying to code the examples in the book and when they did not work as expected (Used Hibernate and MySQL) .

Please help me with the problem and let me know if further details required.

Thanks
 
Sudhanshu Mishra
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any replies?
I think I have provided the complete details, still if further information required please reply.

 
Sudhanshu Mishra
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Is my question missing any details?
If not, why no answers yet?
 
Greenhorn
Posts: 12
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sudhanshu Mishra,

Although you created a valid generator, you still need to override the default generation strategy, as follows:



There's no need for pushing anyone for answers, alright?!
 
Sudhanshu Mishra
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply,Rafael de Sousa
If you read the question completly, I also referred that it was mentioned in the Pro JPA 2 book.
Thanks for helping me get this straight though.
 
Today you are you, that is turer than true. There is no one alive who is youer than you! - Seuss. Tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic