Skip to content

Commit 3ca7185

Browse files
authored
Merge pull request #4 from Sassine/refactor/jpa-repository-import
refactor: JPA Repository Import and expands class Interface
2 parents 9cc908c + ad5d70d commit 3ca7185

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

sqlschema2java-core/src/main/java/dev/sassine/api/structure/export/builder/factory/impl/RepositoryFactory.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.burningwave.core.classes.GenericSourceGenerator;
1717
import org.burningwave.core.classes.TypeDeclarationSourceGenerator;
1818
import org.burningwave.core.classes.UnitSourceGenerator;
19+
import org.springframework.data.jpa.repository.JpaRepository;
1920
import org.springframework.stereotype.Repository;
2021

2122
import dev.sassine.api.structure.export.builder.factory.Factory;
@@ -25,8 +26,6 @@ public class RepositoryFactory implements Factory {
2526

2627
private static final Logger log = getLogger();
2728

28-
private static final String PACKAGE_JPAREPOSITORY = "org.springframework.data.jpa.repository.JpaRepository";
29-
private static final String CLASSNAME_JPAREPOSITORY = "JpaRepository";
3029
private static final String DOT_REPOSITORY = ".repository";
3130
private static final String ENTITY_REPOSITORY = "EntityRepository";
3231
private static final String ENTITY = "Entity";
@@ -39,16 +38,15 @@ public void execute(EntityModel entityModel, boolean isAutoGenerated, String nam
3938
ClassSourceGenerator interfaceClass = this.buildClassSource(entityModel, nameClass);
4039
log.debug("InterfaceRepository builded");
4140
importEntityClass(nameClass, packageName, gen);
42-
gen.addImport(PACKAGE_JPAREPOSITORY);
4341
gen.addClass(interfaceClass);
4442
store(gen);
4543
log.debug("Repository EntityClass ({}) stored", nameClass);
4644
}
4745

4846
private ClassSourceGenerator buildClassSource(EntityModel entityModel, String nameClass) {
4947
return ClassSourceGenerator
50-
.createInterface(TypeDeclarationSourceGenerator.create(ENTITY_REPOSITORY))
51-
.expands(TypeDeclarationSourceGenerator.create(CLASSNAME_JPAREPOSITORY)
48+
.createInterface(TypeDeclarationSourceGenerator.create(nameClass.concat(ENTITY_REPOSITORY)))
49+
.expands(TypeDeclarationSourceGenerator.create(JpaRepository.class)
5250
.addGeneric(GenericSourceGenerator.create(nameClass.concat(ENTITY)))
5351
.addGeneric(GenericSourceGenerator.create(this.getIdClassType(entityModel))))
5452
.addModifier(PUBLIC)

0 commit comments

Comments
 (0)