deltaspike-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominik Obermaier <dominik.oberma...@gmail.com>
Subject Deltaspike Data - Abstract Repositories
Date Sat, 16 Aug 2014 23:19:27 GMT
I've successfully migrated a self-made repository framework 
implementation to Deltaspike Data and so far it's a breeze!

The only thing I'm wondering is how to build custom abstract 
repositories with convenience methods all concrete repositories should 
inherit.

The scenario is the following:

* All entities extend an AbstractEntity (with fields like 'uuid', 
'lastUpdated' and the 'id')
* I want to introduce an abstract repository (AbstractRepository) 
implementation with methods like "findByUuid", "getLastUpdated", ...
* All concrete repositories are abstract classes and should inherit from 
AbstractRepository


My naive (and non-working) approach was to write the following 4 classes:

Entites:
------------
@MappedSuperclass
public class AbstractEntity implements Serializable { ... }

@Entity
public class User extends AbstractEntity { ... }

Repositories:
--------------------
public abstract class AbstractRepository<T extends AbstractEntity> 
extends AbstractEntityRepository<T, Long> {
}

@Repository
public abstract class UserRepository extends AbstractRepository<User> {
}



When I try to deploy that; I'm getting the following exception:

org.apache.deltaspike.data.impl.RepositoryDefinitionException: 
Repository creation for class class 
com.acme.repository.AbstractRepository failed. Is it associated with a 
valid Entity?
     at 
org.apache.deltaspike.data.impl.meta.RepositoryComponents.extractEntityMetaData(RepositoryComponents.java:118)
     at 
org.apache.deltaspike.data.impl.meta.RepositoryComponents.add(RepositoryComponents.java:56)
     at 
org.apache.deltaspike.data.impl.RepositoryExtension.processAnnotatedType(RepositoryExtension.java:90)
---- SNIP ----



Is there something obvious I'm doing wrong? I'm glad for any help!

All the best,
Dominik



Mime
View raw message