openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Handerson <handerson.go...@gmail.com>
Subject Generic Id on MappedSupperclass
Date Wed, 31 Dec 2008 21:30:40 GMT

I have an Identifiable supper class that I want to use as a holder for Id for
my persistent subclasses. The subclasses may use a String or Long as the
primary key.

When OpenJPA tries to create the table it is mapping a Long id in my class
to a Blob field on oracle.
The query generated looks like this, note the Primary Key parenthesis is
empty:

CREATE TABLE Group (id BLOB, createdBy VARCHAR2(255), createdDateTime
TIMESTAMP, updatedBy VARCHAR2(255), updatedDateTime TIMESTAMP, name
VARCHAR2(255), PRIMARY KEY ())



Have anyone successfully tried this kind of mapping on OpenJPA? 

I'm migrating from Hibernate to OpenJPA and this was working using standard
JPA annotations.

I'm using OpenJPA 1.2.0 and Spring 2.5.


This is the OpenJPA Log with TRACE enabled:

2594  persistenceUnit  TRACE  [main] openjpa.MetaData - 	Resolving field
"com.vo.admin.Group@353244430.id".
2594  persistenceUnit  TRACE  [main] openjpa.MetaData - 	"id" has mapping
strategy "org.apache.openjpa.jdbc.meta.strats.MaxEmbeddedBlobFieldStrategy".



The Identifiable mappedSupperclass

@MappedSuperclass
public abstract class Identifiable&lt;T extends Serializable&gt; 
                implements Comparable, Serializable {
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private T id;
        
        public Identifiable() {
		super();
	}

	public Identifiable(T id) {
		super();
		this.id = id;
	}

	public T getId() {
		return id;
	}

	public void setId(T id) {
		this.id = id;
	}
}



The Subclass

@Entity
public abstract class Group extends Identifiable&lt;Long&gt; {
        String name;
        public String getName(){ return name; }
        public void setName(String name) { this.name= name; }
}


Any help is appreciated.
Thanks,
Handerson
-- 
View this message in context: http://n2.nabble.com/Generic-Id-on-MappedSupperclass-tp2097331p2097331.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message