mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#225 - Mapping - Add / review support for @IdClass
This commit is contained in:
@@ -3,6 +3,7 @@ package io.ebeaninternal.server.deploy.parse;
|
||||
import io.ebeaninternal.server.deploy.BeanCascadeInfo;
|
||||
import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
|
||||
import io.ebeaninternal.server.deploy.meta.DeployBeanProperty;
|
||||
import io.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssoc;
|
||||
import io.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssocOne;
|
||||
|
||||
import javax.persistence.AttributeOverride;
|
||||
@@ -11,6 +12,7 @@ import javax.persistence.Column;
|
||||
import javax.validation.groups.Default;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Base class for reading deployment annotations.
|
||||
@@ -39,6 +41,36 @@ public abstract class AnnotationParser extends AnnotationBase {
|
||||
@Override
|
||||
public abstract void parse();
|
||||
|
||||
/**
|
||||
* Read the Id annotation on an embeddedId.
|
||||
*/
|
||||
protected void readIdAssocOne(DeployBeanPropertyAssoc<?> prop) {
|
||||
prop.setNullable(false);
|
||||
if (prop.isIdClass()) {
|
||||
prop.setImportedPrimaryKey();
|
||||
} else {
|
||||
prop.setId();
|
||||
prop.setEmbedded();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the Id annotation on scalar property.
|
||||
*/
|
||||
protected void readIdScalar(DeployBeanProperty prop) {
|
||||
prop.setNullable(false);
|
||||
if (prop.isIdClass()) {
|
||||
prop.setImportedPrimaryKey();
|
||||
} else {
|
||||
prop.setId();
|
||||
if (prop.getPropertyType().equals(UUID.class)) {
|
||||
if (descriptor.getIdGeneratorName() == null) {
|
||||
descriptor.setUuidGenerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to set cascade types to the CascadeInfo on BeanProperty.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user