Skip to content

Commit d4e261c

Browse files
author
eugenp
committed
introducing jpa 2 metamodel and initial work on search/filter functionality
1 parent 4d90335 commit d4e261c

14 files changed

Lines changed: 220 additions & 20 deletions

‎eclipse/INTEGRATION-SINGLE.launch‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
22
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
33
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
4-
<listEntry value="/rest/src/test/java/org/rest/sec/web/privilege/PrivilegeLogicRESTIntegrationTest.java"/>
4+
<listEntry value="/rest/src/test/java/org/rest/sec/persistence/service/RoleServiceSearchPersistenceIntegrationTest.java"/>
55
</listAttribute>
66
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
77
<listEntry value="1"/>
@@ -12,10 +12,10 @@
1212
</mapAttribute>
1313
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
1414
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
15-
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value="whenResourcesAreRetrieved_thenResourcesAreCorrectlyRetrieved"/>
15+
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
1616
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
1717
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
18-
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.rest.sec.web.privilege.PrivilegeLogicRESTIntegrationTest"/>
18+
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.rest.sec.persistence.service.RoleServiceSearchPersistenceIntegrationTest"/>
1919
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="rest"/>
2020
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
2121
</launchConfiguration>

‎pom.xml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211

212212
<dependency>
213213
<groupId>junit</groupId>
214-
<artifactId>junit</artifactId>
214+
<artifactId>junit-dep</artifactId>
215215
<version>${junit.version}</version>
216216
<scope>test</scope>
217217
</dependency>
@@ -356,7 +356,7 @@
356356
<phase>generate-sources</phase>
357357
<configuration>
358358
source output directory
359-
<outputDirectory>target/metamodel</outputDirectory>
359+
<outputDirectory>src/main/java</outputDirectory>
360360
</configuration>
361361
</execution>
362362
</executions>
@@ -374,7 +374,7 @@
374374
</goals>
375375
<configuration>
376376
<sources>
377-
<source>target/metamodel</source>
377+
<source>src/main/java/org/rest/persistence/metamodel</source>
378378
</sources>
379379
</configuration>
380380
</execution>

‎src/main/java/org/rest/persistence/service/AbstractService.java‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,8 @@ public void delete( final long id ){
9191
this.getDao().delete( id );
9292
}
9393

94-
// search
95-
96-
public List< T > search(){
97-
// getDao().
98-
return null;
99-
}
100-
10194
//
95+
10296
protected abstract PagingAndSortingRepository< T, Long > getDao();
10397

10498
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.rest.sec.model;
2+
3+
import javax.annotation.Generated;
4+
import javax.persistence.metamodel.SetAttribute;
5+
import javax.persistence.metamodel.SingularAttribute;
6+
import javax.persistence.metamodel.StaticMetamodel;
7+
8+
@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor")
9+
@StaticMetamodel(Principal.class)
10+
public abstract class Principal_ {
11+
12+
public static volatile SingularAttribute<Principal, Long> id;
13+
public static volatile SetAttribute<Principal, Role> roles;
14+
public static volatile SingularAttribute<Principal, String> name;
15+
public static volatile SingularAttribute<Principal, String> password;
16+
17+
}
18+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.rest.sec.model;
2+
3+
import javax.annotation.Generated;
4+
import javax.persistence.metamodel.SingularAttribute;
5+
import javax.persistence.metamodel.StaticMetamodel;
6+
7+
@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor")
8+
@StaticMetamodel(Privilege.class)
9+
public abstract class Privilege_ {
10+
11+
public static volatile SingularAttribute<Privilege, Long> id;
12+
public static volatile SingularAttribute<Privilege, String> name;
13+
14+
}
15+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.rest.sec.model;
2+
3+
import javax.annotation.Generated;
4+
import javax.persistence.metamodel.SetAttribute;
5+
import javax.persistence.metamodel.SingularAttribute;
6+
import javax.persistence.metamodel.StaticMetamodel;
7+
8+
@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor")
9+
@StaticMetamodel(Role.class)
10+
public abstract class Role_ {
11+
12+
public static volatile SingularAttribute<Role, Long> id;
13+
public static volatile SingularAttribute<Role, String> name;
14+
public static volatile SetAttribute<Role, Privilege> privileges;
15+
16+
}
17+

‎src/main/java/org/rest/sec/persistence/dao/IPrincipalJpaDAO.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
import org.rest.sec.model.Principal;
44
import org.springframework.data.jpa.repository.JpaRepository;
5+
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
56

6-
public interface IPrincipalJpaDAO extends JpaRepository< Principal, Long >{
7+
public interface IPrincipalJpaDAO extends JpaRepository< Principal, Long >, JpaSpecificationExecutor< Principal >{
78

89
Principal findByName( final String name );
910

‎src/main/java/org/rest/sec/persistence/dao/IRoleJpaDAO.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
import org.rest.sec.model.Role;
44
import org.springframework.data.jpa.repository.JpaRepository;
5+
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
56

6-
public interface IRoleJpaDAO extends JpaRepository< Role, Long >{
7+
public interface IRoleJpaDAO extends JpaRepository< Role, Long >, JpaSpecificationExecutor< Role >{
78

89
Role findByName( final String name );
910

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
package org.rest.sec.persistence.service;
22

3+
import java.util.List;
4+
5+
import org.apache.commons.lang3.tuple.ImmutablePair;
36
import org.rest.persistence.service.IService;
47
import org.rest.sec.model.Role;
58

69
public interface IRoleService extends IService< Role >{
710

811
Role findByName( final String name );
912

13+
List< Role > search( final Long id );
14+
15+
List< Role > search( final ImmutablePair< String, String >... constraints );
16+
1017
}

‎src/main/java/org/rest/sec/persistence/service/impl/PrincipalServiceImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public PrincipalServiceImpl(){
1919
}
2020

2121
// API
22-
22+
2323
@Override
2424
@Transactional( readOnly = true )
2525
public Principal findByName( final String name ){

0 commit comments

Comments
 (0)