ad.setValue( "targetEntity", oneToOne.targetEntity() ); ad.setValue( "fetch", oneToOne.fetch() ); ad.setValue( "optional", oneToOne.optional() ); ad.setValue( "mappedBy", oneToOne.mappedBy() ); ad.setValue( "orphanRemoval", oneToOne.orphanRemoval() );
Arrays.asList(oneToOneAnn.cascade()), oneToOneAnn.optional(), oneToOneAnn.mappedBy(), Relation.ForeignKey.ONE_TO_ONE);
/** * INTERNAL: */ public boolean isOptional() { return (m_oneToOne == null) ? true : m_oneToOne.optional(); }
private void readOneToOne(OneToOne propAnn, DeployBeanPropertyAssocOne<?> prop) { prop.setOneToOne(); prop.setDbInsertable(true); prop.setDbUpdateable(true); prop.setNullable(propAnn.optional()); prop.setFetchType(propAnn.fetch()); prop.setMappedBy(propAnn.mappedBy()); if (!"".equals(propAnn.mappedBy())) { prop.setOneToOneExported(); prop.setOrphanRemoval(propAnn.orphanRemoval()); } else if (propAnn.orphanRemoval()) { prop.setOrphanRemoval(true); } setCascadeTypes(propAnn.cascade(), prop.getCascadeInfo()); prop.setBeanTable(beanTable(prop)); }
!ann.optional() || property.isAnnotationPresent( Id.class ) || ( property.isAnnotationPresent( MapsId.class ) && !ignoreNotFound );
protected boolean isMandatory(Field field) { OneToMany oneToManyAnnotation = field.getAnnotation(OneToMany.class); ManyToMany manyToManyAnnotation = field.getAnnotation(ManyToMany.class); if (oneToManyAnnotation != null || manyToManyAnnotation != null) { return false; } Column columnAnnotation = field.getAnnotation(Column.class); OneToOne oneToOneAnnotation = field.getAnnotation(OneToOne.class); ManyToOne manyToOneAnnotation = field.getAnnotation(ManyToOne.class); com.haulmont.chile.core.annotations.MetaProperty metaPropertyAnnotation = field.getAnnotation(com.haulmont.chile.core.annotations.MetaProperty.class); boolean superMandatory = (metaPropertyAnnotation != null && metaPropertyAnnotation.mandatory()) || (field.getAnnotation(NotNull.class) != null && isDefinedForDefaultValidationGroup(field.getAnnotation(NotNull.class))); // @NotNull without groups return (columnAnnotation != null && !columnAnnotation.nullable()) || (oneToOneAnnotation != null && !oneToOneAnnotation.optional()) || (manyToOneAnnotation != null && !manyToOneAnnotation.optional()) || superMandatory; }
protected boolean isRequired(MetaProperty metaProperty) { if (metaProperty.isMandatory()) return true; ManyToOne many2One = metaProperty.getAnnotatedElement().getAnnotation(ManyToOne.class); if (many2One != null && !many2One.optional()) return true; OneToOne one2one = metaProperty.getAnnotatedElement().getAnnotation(OneToOne.class); return one2one != null && !one2one.optional(); }
private void introspectOneToOne(OneToOne oneToOne) { Class targetClass = oneToOne.targetEntity(); if (void.class.equals(targetClass)) targetClass = _fieldType; setTargetEntity(targetClass); setCascadeTypes(oneToOne.cascade()); setFetch(oneToOne.fetch()); _isOptional = oneToOne.optional(); _mappedBy = oneToOne.mappedBy(); }
ad.setValue( "targetEntity", oneToOne.targetEntity() ); ad.setValue( "fetch", oneToOne.fetch() ); ad.setValue( "optional", oneToOne.optional() ); ad.setValue( "mappedBy", oneToOne.mappedBy() ); ad.setValue( "orphanRemoval", oneToOne.orphanRemoval() );
this.optional = oneToOne.optional(); this.removesOprhans = oneToOne.orphanRemoval(); this.mapsId = this.handleMapsId(member, parsed);
private void readOneToOne(OneToOne propAnn, DeployBeanPropertyAssocOne<?> prop) { prop.setOneToOne(true); prop.setDbInsertable(true); prop.setDbUpdateable(true); prop.setNullable(propAnn.optional()); prop.setFetchType(propAnn.fetch()); prop.setMappedBy(propAnn.mappedBy()); if (!"".equals(propAnn.mappedBy())) { prop.setOneToOneExported(true); } setCascadeTypes(propAnn.cascade(), prop.getCascadeInfo()); BeanTable assoc = factory.getBeanTable(prop.getPropertyType()); if (assoc == null) { String msg = errorMsgMissingBeanTable(prop.getPropertyType(), prop.getFullBeanName()); throw new RuntimeException(msg); } prop.setBeanTable(assoc); }
private void readOneToOne(OneToOne propAnn, DeployBeanPropertyAssocOne<?> prop) { prop.setOneToOne(); prop.setDbInsertable(true); prop.setDbUpdateable(true); prop.setNullable(propAnn.optional()); prop.setFetchType(propAnn.fetch()); prop.setMappedBy(propAnn.mappedBy()); if (!"".equals(propAnn.mappedBy())) { prop.setOneToOneExported(); } setCascadeTypes(propAnn.cascade(), prop.getCascadeInfo()); BeanTable assoc = factory.getBeanTable(prop.getPropertyType()); if (assoc == null) { String msg = errorMsgMissingBeanTable(prop.getPropertyType(), prop.getFullBeanName()); throw new RuntimeException(msg); } prop.setBeanTable(assoc); }
private void readOneToOne(OneToOne propAnn, DeployBeanPropertyAssocOne<?> prop) { prop.setOneToOne(true); prop.setDbInsertable(true); prop.setDbUpdateable(true); prop.setNullable(propAnn.optional()); prop.setFetchType(propAnn.fetch()); prop.setMappedBy(propAnn.mappedBy()); if (!"".equals(propAnn.mappedBy())) { prop.setOneToOneExported(true); } setCascadeTypes(propAnn.cascade(), prop.getCascadeInfo()); BeanTable assoc = factory.getBeanTable(prop.getPropertyType()); if (assoc == null) { String msg = errorMsgMissingBeanTable(prop.getPropertyType(), prop.getFullBeanName()); throw new RuntimeException(msg); } prop.setBeanTable(assoc); }
/** * Parse @OneToOne. */ private void parseOneToOne(FieldMetaData fmd, OneToOne anno) { if (!JavaTypes.maybePC(fmd.getValue())) throw new MetaDataException(_loc.get("bad-meta-anno", fmd, "OneToOne")); // don't specifically exclude relation from DFG b/c that will prevent // us from even reading the fk when reading from the primary table, // which is not what most users will want if (anno.fetch() == FetchType.EAGER) fmd.setInDefaultFetchGroup(true); if (!anno.optional()) fmd.setNullValue(FieldMetaData.NULL_EXCEPTION); if (isMappingOverrideMode() && !StringUtils.isEmpty(anno.mappedBy())) fmd.setMappedBy(anno.mappedBy()); if (anno.targetEntity() != void.class) fmd.setTypeOverride(anno.targetEntity()); setCascades(fmd, anno.cascade()); }
private void readOneToOne(OneToOne propAnn, DeployBeanPropertyAssocOne<?> prop) { prop.setOneToOne(); prop.setDbInsertable(true); prop.setDbUpdateable(true); prop.setNullable(propAnn.optional()); prop.setFetchType(propAnn.fetch()); prop.setMappedBy(propAnn.mappedBy()); if (!"".equals(propAnn.mappedBy())) { prop.setOneToOneExported(); prop.setOrphanRemoval(propAnn.orphanRemoval()); } else if (propAnn.orphanRemoval()) { prop.setOrphanRemoval(true); } setCascadeTypes(propAnn.cascade(), prop.getCascadeInfo()); prop.setBeanTable(beanTable(prop)); }
final boolean mandatory = !ann.optional() || forcePersist || trueOneToOne;
/** * Parse @OneToOne. */ private void parseOneToOne(FieldMetaData fmd, OneToOne anno) { if (!JavaTypes.maybePC(fmd.getValue())) throw new MetaDataException(_loc.get("bad-meta-anno", fmd, "OneToOne")); // don't specifically exclude relation from DFG b/c that will prevent // us from even reading the fk when reading from the primary table, // which is not what most users will want if (anno.fetch() == FetchType.EAGER) fmd.setInDefaultFetchGroup(true); if (!anno.optional()) fmd.setNullValue(FieldMetaData.NULL_EXCEPTION); if (isMappingOverrideMode() && !StringUtils.isEmpty(anno.mappedBy())) fmd.setMappedBy(anno.mappedBy()); if (anno.targetEntity() != void.class) fmd.setTypeOverride(anno.targetEntity()); setCascades(fmd, anno.cascade()); setOrphanRemoval(fmd, anno.orphanRemoval()); fmd.setAssociationType(FieldMetaData.ONE_TO_ONE); }
/** * Parse @OneToOne. */ private void parseOneToOne(FieldMetaData fmd, OneToOne anno) { if (!JavaTypes.maybePC(fmd.getValue())) throw new MetaDataException(_loc.get("bad-meta-anno", fmd, "OneToOne")); // don't specifically exclude relation from DFG b/c that will prevent // us from even reading the fk when reading from the primary table, // which is not what most users will want if (anno.fetch() == FetchType.EAGER) fmd.setInDefaultFetchGroup(true); if (!anno.optional()) fmd.setNullValue(FieldMetaData.NULL_EXCEPTION); if (isMappingOverrideMode() && !StringUtils.isEmpty(anno.mappedBy())) fmd.setMappedBy(anno.mappedBy()); if (anno.targetEntity() != void.class) fmd.setTypeOverride(anno.targetEntity()); setCascades(fmd, anno.cascade()); setOrphanRemoval(fmd, anno.orphanRemoval()); fmd.setAssociationType(FieldMetaData.ONE_TO_ONE); }
/** * Parse @OneToOne. */ private void parseOneToOne(FieldMetaData fmd, OneToOne anno) { if (!JavaTypes.maybePC(fmd.getValue())) throw new MetaDataException(_loc.get("bad-meta-anno", fmd, "OneToOne")); // don't specifically exclude relation from DFG b/c that will prevent // us from even reading the fk when reading from the primary table, // which is not what most users will want if (anno.fetch() == FetchType.EAGER) fmd.setInDefaultFetchGroup(true); if (!anno.optional()) fmd.setNullValue(FieldMetaData.NULL_EXCEPTION); if (isMappingOverrideMode() && !StringUtil.isEmpty(anno.mappedBy())) fmd.setMappedBy(anno.mappedBy()); if (anno.targetEntity() != void.class) fmd.setTypeOverride(anno.targetEntity()); setCascades(fmd, anno.cascade()); setOrphanRemoval(fmd, anno.orphanRemoval()); fmd.setAssociationType(FieldMetaData.ONE_TO_ONE); }
/** * Parse @OneToOne. */ private void parseOneToOne(FieldMetaData fmd, OneToOne anno) { if (!JavaTypes.maybePC(fmd.getValue())) throw new MetaDataException(_loc.get("bad-meta-anno", fmd, "OneToOne")); // don't specifically exclude relation from DFG b/c that will prevent // us from even reading the fk when reading from the primary table, // which is not what most users will want if (anno.fetch() == FetchType.EAGER) fmd.setInDefaultFetchGroup(true); if (!anno.optional()) fmd.setNullValue(FieldMetaData.NULL_EXCEPTION); if (isMappingOverrideMode() && !StringUtil.isEmpty(anno.mappedBy())) fmd.setMappedBy(anno.mappedBy()); if (anno.targetEntity() != void.class) fmd.setTypeOverride(anno.targetEntity()); setCascades(fmd, anno.cascade()); setOrphanRemoval(fmd, anno.orphanRemoval()); fmd.setAssociationType(FieldMetaData.ONE_TO_ONE); }