Created
September 4, 2018 18:32
-
-
Save aploskov/71c8079e0febe584b1d33daa79aedb0c to your computer and use it in GitHub Desktop.
Entity.Id должен быть Id для сущности Hibernate, вот в чём фишка
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example; | |
import java.io.Serializable; | |
import java.util.List; | |
interface HasId<Id extends Serializable, Entity extends HasId<Id, Entity>> { | |
Id getId(); | |
Entity setId(final Id id); | |
} | |
interface Service<Id extends Serializable, C extends HasId<Id, C>> { | |
C getById(final Id id); | |
} | |
interface ConcreteService extends Service<Entity.Id, Entity> { | |
/** | |
* @param id проблема тут, мне нужно убедиться, что id - это {@link Entity#id}, а не id другой сущности. | |
* @param <T> другая сущность, получаемая по {@link Entity#id}. | |
* @return список этих блядских сущностей. | |
*/ | |
<T> List<T> getTList(final Entity.Id id); | |
} | |
final class Entity implements HasId<Entity.Id, Entity> { | |
private Id id; | |
@Override | |
public Id getId() { | |
return null; | |
} | |
@Override | |
public Entity setId(Id id) { | |
return null; | |
} | |
final class Id implements Serializable {} | |
} | |
final class ConcreteServiceImpl implements ConcreteService { | |
@Override | |
public Entity getById(Entity.Id integer) { | |
return null; | |
} | |
@Override | |
public <T> List<T> getTList(Entity.Id id) { | |
return null; | |
} | |
} | |
public class Main { | |
public static void main(String[] args) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment