@Test public void testGetEntityModel() throws Exception { AttributeDesc id = new AttributeDesc(); id.setName("id"); id.setId(true); id.setGenerationType(GenerationType.AUTO); id.setAttributeClass(int.class); AttributeDesc name = new AttributeDesc(); name.setName("name"); name.setAttributeClass(String.class); AttributeDesc lob = new AttributeDesc(); lob.setName("lob"); lob.setLob(true); lob.setAttributeClass(byte[].class); AttributeDesc date = new AttributeDesc(); date.setName("date"); date.setAttributeClass(java.sql.Date.class); AttributeDesc temp = new AttributeDesc(); temp.setName("temp"); temp.setTransient(true); temp.setAttributeClass(String.class); AttributeDesc version = new AttributeDesc(); version.setName("version"); version.setVersion(true); version.setAttributeClass(Integer.class); EntityDesc entityDesc = new EntityDesc(); entityDesc.setCatalogName("AAA"); entityDesc.setSchemaName("BBB"); entityDesc.setTableName("FOO"); entityDesc.setName("Foo"); entityDesc.addAttributeDesc(id); entityDesc.addAttributeDesc(name); entityDesc.addAttributeDesc(lob); entityDesc.addAttributeDesc(date); entityDesc.addAttributeDesc(temp); entityDesc.addAttributeDesc(version); EntityModel model = factory.getEntityModel(entityDesc); assertEquals("aaa.bbb", model.getPackageName()); assertEquals("Foo", model.getShortClassName()); assertEquals("AAA", model.getCatalogName()); assertEquals("BBB", model.getSchemaName()); assertEquals("FOO", model.getTableName()); Set<String> set = model.getImportNameSet(); assertEquals(15, set.size()); Iterator<String> iterator = set.iterator(); assertEquals(Serializable.class.getCanonicalName(), iterator.next()); assertEquals(Date.class.getCanonicalName(), iterator.next()); assertEquals(Generated.class.getCanonicalName(), iterator.next()); assertEquals(Column.class.getCanonicalName(), iterator.next()); assertEquals(Entity.class.getCanonicalName(), iterator.next()); assertEquals(GeneratedValue.class.getCanonicalName(), iterator.next()); assertEquals(GenerationType.class.getCanonicalName(), iterator.next()); assertEquals(Id.class.getCanonicalName(), iterator.next()); assertEquals(Lob.class.getCanonicalName(), iterator.next()); assertEquals(Table.class.getCanonicalName(), iterator.next()); assertEquals(Temporal.class.getCanonicalName(), iterator.next()); assertEquals(TemporalType.class.getCanonicalName(), iterator.next()); assertEquals(Transient.class.getCanonicalName(), iterator.next()); assertEquals(Version.class.getCanonicalName(), iterator.next()); assertEquals(Superclass.class.getCanonicalName(), iterator.next()); }
public EntityModel getEntityModel(EntityDesc entityDesc) { EntityModel entityModel = new EntityModel(); if (showCatalogName) { entityModel.setCatalogName(entityDesc.getCatalogName()); } if (showSchemaName) { entityModel.setSchemaName(entityDesc.getSchemaName()); } if (showTableName) { entityModel.setTableName(entityDesc.getTableName()); } entityModel.setPackageName(packageName); entityModel.setShortClassName(entityDesc.getName()); if (superclass != null) { entityModel.setShortSuperclassName(superclass.getSimpleName()); } entityModel.setCompositeId(entityDesc.hasCompositeId()); entityModel.setUseAccessor(useAccessor); entityModel.setComment(entityDesc.getComment()); entityModel.setUseComment(useComment); doAttributeModel(entityModel, entityDesc); doAssociationModel(entityModel, entityDesc); doCompositeUniqueConstraintModel(entityModel, entityDesc); doImportName(entityModel, entityDesc); doGeneratedInfo(entityModel, entityDesc); return entityModel; }
EntityModelFactoryImpl implements EntityModelFactory { public EntityModel getEntityModel(EntityDesc entityDesc) { EntityModel entityModel = new EntityModel(); if (showCatalogName) { entityModel.setCatalogName(entityDesc.getCatalogName()); } if (showSchemaName) { entityModel.setSchemaName(entityDesc.getSchemaName()); } if (showTableName) { entityModel.setTableName(entityDesc.getTableName()); } entityModel.setPackageName(packageName); entityModel.setShortClassName(entityDesc.getName()); if (superclass != null) { entityModel.setShortSuperclassName(superclass.getSimpleName()); } entityModel.setCompositeId(entityDesc.hasCompositeId()); entityModel.setUseAccessor(useAccessor); entityModel.setComment(entityDesc.getComment()); entityModel.setUseComment(useComment); doAttributeModel(entityModel, entityDesc); doAssociationModel(entityModel, entityDesc); doCompositeUniqueConstraintModel(entityModel, entityDesc); doImportName(entityModel, entityDesc); doGeneratedInfo(entityModel, entityDesc); return entityModel; } }
EntityModelFactoryImpl implements EntityModelFactory { public EntityModel getEntityModel(EntityDesc entityDesc) { EntityModel entityModel = new EntityModel(); if (showCatalogName) { entityModel.setCatalogName(entityDesc.getCatalogName()); } if (showSchemaName) { entityModel.setSchemaName(entityDesc.getSchemaName()); } if (showTableName) { entityModel.setTableName(entityDesc.getTableName()); } entityModel.setPackageName(packageName); entityModel.setShortClassName(entityDesc.getName()); if (superclass != null) { entityModel.setShortSuperclassName(superclass.getSimpleName()); } entityModel.setCompositeId(entityDesc.hasCompositeId()); entityModel.setUseAccessor(useAccessor); entityModel.setComment(entityDesc.getComment()); entityModel.setUseComment(useComment); doAttributeModel(entityModel, entityDesc); doAssociationModel(entityModel, entityDesc); doCompositeUniqueConstraintModel(entityModel, entityDesc); doImportName(entityModel, entityDesc); doGeneratedInfo(entityModel, entityDesc); return entityModel; } EntityModelFactoryImpl(
            String packageName,
            Class<?> superclass,
            AttributeModelFactory attributeModelFactory,
            AssociationModelFactory associationModelFactory,
            CompositeUniqueConstraintModelFactory compositeUniqueConstraintModelFactory,
            boolean useAccessor, boolean useComment, boolean showCatalogName,
            boolean showSchemaName, boolean showTableName); }
EntityModelFactoryImpl implements EntityModelFactory { public EntityModel getEntityModel(EntityDesc entityDesc) { EntityModel entityModel = new EntityModel(); if (showCatalogName) { entityModel.setCatalogName(entityDesc.getCatalogName()); } if (showSchemaName) { entityModel.setSchemaName(entityDesc.getSchemaName()); } if (showTableName) { entityModel.setTableName(entityDesc.getTableName()); } entityModel.setPackageName(packageName); entityModel.setShortClassName(entityDesc.getName()); if (superclass != null) { entityModel.setShortSuperclassName(superclass.getSimpleName()); } entityModel.setCompositeId(entityDesc.hasCompositeId()); entityModel.setUseAccessor(useAccessor); entityModel.setComment(entityDesc.getComment()); entityModel.setUseComment(useComment); doAttributeModel(entityModel, entityDesc); doAssociationModel(entityModel, entityDesc); doCompositeUniqueConstraintModel(entityModel, entityDesc); doImportName(entityModel, entityDesc); doGeneratedInfo(entityModel, entityDesc); return entityModel; } EntityModelFactoryImpl(
            String packageName,
            Class<?> superclass,
            AttributeModelFactory attributeModelFactory,
            AssociationModelFactory associationModelFactory,
            CompositeUniqueConstraintModelFactory compositeUniqueConstraintModelFactory,
            boolean useAccessor, boolean useComment, boolean showCatalogName,
            boolean showSchemaName, boolean showTableName); EntityModel getEntityModel(EntityDesc entityDesc); }
EntityModelFactoryImpl implements EntityModelFactory { public EntityModel getEntityModel(EntityDesc entityDesc) { EntityModel entityModel = new EntityModel(); if (showCatalogName) { entityModel.setCatalogName(entityDesc.getCatalogName()); } if (showSchemaName) { entityModel.setSchemaName(entityDesc.getSchemaName()); } if (showTableName) { entityModel.setTableName(entityDesc.getTableName()); } entityModel.setPackageName(packageName); entityModel.setShortClassName(entityDesc.getName()); if (superclass != null) { entityModel.setShortSuperclassName(superclass.getSimpleName()); } entityModel.setCompositeId(entityDesc.hasCompositeId()); entityModel.setUseAccessor(useAccessor); entityModel.setComment(entityDesc.getComment()); entityModel.setUseComment(useComment); doAttributeModel(entityModel, entityDesc); doAssociationModel(entityModel, entityDesc); doCompositeUniqueConstraintModel(entityModel, entityDesc); doImportName(entityModel, entityDesc); doGeneratedInfo(entityModel, entityDesc); return entityModel; } EntityModelFactoryImpl(
            String packageName,
            Class<?> superclass,
            AttributeModelFactory attributeModelFactory,
            AssociationModelFactory associationModelFactory,
            CompositeUniqueConstraintModelFactory compositeUniqueConstraintModelFactory,
            boolean useAccessor, boolean useComment, boolean showCatalogName,
            boolean showSchemaName, boolean showTableName); EntityModel getEntityModel(EntityDesc entityDesc);  }