Reputation: 170735
Especially when working with JPA v1.0, try not to use id inheritance.
What is the difference with JPA 2? In particular, does it work better, i.e., can a Stapler
and a Chair
in the example have the same id when strategy=GenerationType.IDENTITY
is used? Or does it depend on JPA implementation and/or database driver?
Upvotes: 0
Views: 136
Reputation: 18379
I don't think that blog post makes a whole lot of sense.
I'm not even sure it is possible to not defined the Id in a superclass, unless it is a @MappedSuperclass.
It seems to be worried about running out of Ids. If you could run out of Ids with n subclasses, then you will also run out with one class, just take you n times as much time, which is not much longer. But running out of ids is not a problem as long as you use a long not and int.
A int id will last you about 100 years at one insert per second. Still not "soon", but for higher throughputs possible to run out.
A long will last you about 300 million years at one per millisecond. Not very "soon".
See, http://en.wikibooks.org/wiki/Java_Persistence/Identity_and_Sequencing#Running_Out_of_Numbers
Upvotes: 2