Skip to content

Instantly share code, notes, and snippets.

@vojkny
Created February 14, 2012 09:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vojkny/1824989 to your computer and use it in GitHub Desktop.
Save vojkny/1824989 to your computer and use it in GitHub Desktop.
/* what I would like to achieve: */
public interface ItemRepository<T> {
@Query("select distinct a from " + TABLE_NAME + " a " + "join ti.tags tt where tt = ?1")
public List<T> findByTag(Tag t); }
}
public interface AaaaRepository extends ItemRepository<Aaaa> {
TABLE_NAME = "Aaaa";
}
/* what we have: */
public interface ItemRepository<T extends Item> extends BaseRepository<T> {
final static String DISTINCT_ITEM = "select distinct ti from ";
final static String BY_TAG = "join ti.tags tt where tt = ?1";
public List<T> findByTag(Tag tag);
}
public interface AaaaRepository extends ItemRepository<Event> {
final static String ITEM = "Aaaa";
@Override
@Query(DISTINCT_ITEM + ITEM + BY_TAG)
public List<Aaaaa> findByTag(Tag tag); // duplicate
}
public interface BbbbRepository extends ItemRepository<Event> {
final static String ITEM = "Bbbb";
@Override
@Query(DISTINCT_ITEM + ITEM + BY_TAG)
public List<Bbbb> findByTag(Tag tag); // duplicate
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment