Warning

 

Close
Confirm Action

Are you sure you wish to do this?

Cancel Confirm
AR15.COM
2/23/2009 11:27:35 AM EDT
––Posted in GD for wider audience––

Creating a generic notification mechanism for a current project. I'm working on the persistence layer right now and I'm having a hell of a time with Hibernate and Java 1.5 Generics. It looks like hibernate does not like stuff like this:


@Entity
@Table(name="subject_identifier")
public class SubjectIdentifier<T extends Serializable> ...
{
...
   @Column(name="subject_identifier")
   public T getIdentifier() {
       return identifier;
   }
...


...where T is overridden in subclasses to support multiple subject identifier types (Numeric, Strings, Patterns, etc).

I've tried overriding the method in the subclasses with concrete types, but that does not seem to help:


public class NumericSubjectIdentifier extends SubjectIdentifier<Number>
{
...
   public Number getIdentifier() {
       return super.getIdentifier();
   }
...


Generally, hibernate seems a bit kludgely on it's support for generics.

Has anyone played with this combination?