java类javax.persistence.EmbeddedId的实例源码

JpaUtil.java 文件源码 项目:karaf4-eclipselink-jpa 阅读 35 收藏 0 点赞 0 评论 0
private static boolean isManuallyAssigned(final Method method) {
    if (method.getAnnotation(Id.class) != null) {
        return method.getAnnotation(GeneratedValue.class) == null;
    } else if (method.getAnnotation(EmbeddedId.class) != null) {
        return true;
    } else {
        return true;
    }
}
JpaUtil.java 文件源码 项目:rpb 阅读 29 收藏 0 点赞 0 评论 0
private static boolean isManuallyAssigned(Method method) {
    if (method.getAnnotation(Id.class) != null) {
        return method.getAnnotation(GeneratedValue.class) == null;
    } else if (method.getAnnotation(EmbeddedId.class) != null) {
        return true;
    } else {
        return true;
    }
}
JpaUtil.java 文件源码 项目:rpb 阅读 39 收藏 0 点赞 0 评论 0
public static <T extends Identifiable<?>> String compositePkPropertyName(T entity) {
    for (Method m : entity.getClass().getMethods()) {
        if (m.getAnnotation(EmbeddedId.class) != null) {
            return BeanUtils.findPropertyForMethod(m).getName();
        }
    }
    for (Field f : entity.getClass().getFields()) {
        if (f.getAnnotation(EmbeddedId.class) != null) {
            return f.getName();
        }
    }
    return null;
}
StudentClasses.java 文件源码 项目:sample-java-spring-genericdao 阅读 37 收藏 0 点赞 0 评论 0
@EmbeddedId
@AttributeOverrides({
        @AttributeOverride(name = "studentId", column = @Column(name = "STUDENT_ID", nullable = false, precision = 5, scale = 0)),
        @AttributeOverride(name = "classesId", column = @Column(name = "CLASSES_ID", nullable = false, precision = 4, scale = 0)),
        @AttributeOverride(name = "status", column = @Column(name = "STU_CLASSES_STATUS", nullable = false, length = 1)) })

public StudentClassesId getId() {
    return this.id;
}
Assignment.java 文件源码 项目:nics-common 阅读 32 收藏 0 点赞 0 评论 0
@EmbeddedId
@AttributeOverrides({
        @AttributeOverride(name = "unitId", column = @Column(name = "unit_id", nullable = false)),
        @AttributeOverride(name = "operationalPeriodId", column = @Column(name = "operational_period_id", nullable = false)) })
public AssignmentId getId() {
    return this.id;
}
EmbeddedIdColumnEvaluator.java 文件源码 项目:pedal-dialect 阅读 25 收藏 0 点赞 0 评论 0
@Override
public void evaluate(Method method, EvaluatorChain chain) {
    if (method.isAnnotationPresent(EmbeddedId.class)) {
        Map<String, AttributeOverride> overrides = getAttributeOverrides(method);

        Class<?> embeddedClz = method.getReturnType();
        BeanInfo info = null;
        try {
            info = Introspector.getBeanInfo(embeddedClz);
        } catch (IntrospectionException e) {
            throw new RuntimeException(e);
        }
        for (String propertyName : overrides.keySet()) {
            for (PropertyDescriptor propDesc : info.getPropertyDescriptors()) {
                if (propDesc.getName().equals(propertyName)) {
                    CopyAttribute attribute = new CopyAttribute();
                    attribute.getMethods().add(method);
                    attribute.getMethods().add(propDesc.getReadMethod());
                    attribute.setColumnName(overrides.get(propertyName).column().name());
                    chain.add(attribute);
                    break;
                }
            }
        }
    } else {
        chain.doNext();
    }
}
Planet.java 文件源码 项目:pedal-dialect 阅读 29 收藏 0 点赞 0 评论 0
@EmbeddedId
@AttributeOverrides({
        @AttributeOverride(name = "name", column = @Column(name = "name", nullable = false)),
        @AttributeOverride(name = "position", column = @Column(name = "position", nullable = false)) })
public PlanetId getId() {
    return id;
}
PlayersHasInsurances.java 文件源码 项目:watchout 阅读 30 收藏 0 点赞 0 评论 0
@EmbeddedId
@AttributeOverrides({
        @AttributeOverride(name = "playersIdplayers", column = @Column(name = "players_idplayers", nullable = false)),
        @AttributeOverride(name = "insurancesIdinsurances", column = @Column(name = "insurances_idinsurances", nullable = false)) })
public PlayersHasInsurancesId getId() {
    return this.id;
}
TurnsHistory.java 文件源码 项目:watchout 阅读 26 收藏 0 点赞 0 评论 0
@EmbeddedId
@AttributeOverrides({
        @AttributeOverride(name = "playersHasQuestsPlayersIdplayers", column = @Column(name = "players_has_quests_players_idplayers", nullable = false)),
        @AttributeOverride(name = "playersHasQuestsQuestsIdquests", column = @Column(name = "players_has_quests_quests_idquests", nullable = false)),
        @AttributeOverride(name = "placesHasTransportsPlacesOrigin", column = @Column(name = "places_has_transports_places_origin", nullable = false)),
        @AttributeOverride(name = "placesHasTransportsTransportation", column = @Column(name = "places_has_transports_transportation", nullable = false)),
        @AttributeOverride(name = "placesHasTransportsPlacesDestination", column = @Column(name = "places_has_transports_places_destination", nullable = false)) })
public TurnsHistoryId getId() {
    return this.id;
}


问题


面经


文章

微信
公众号

扫码关注公众号