File tree Expand file tree Collapse file tree 6 files changed +14
-14
lines changed
persistence-modules/spring-data-jpa-3/src
test/java/com/baeldung/osiv Expand file tree Collapse file tree 6 files changed +14
-14
lines changed Original file line number Diff line number Diff line change 5
5
6
6
@ Entity
7
7
@ Table (name = "users" )
8
- public class User {
8
+ public class BasicUser {
9
9
10
10
@ Id
11
11
@ GeneratedValue
Original file line number Diff line number Diff line change 1
1
package com .baeldung .repository ;
2
2
3
- import com .baeldung .model .User ;
3
+ import com .baeldung .model .BasicUser ;
4
4
import org .springframework .data .jpa .repository .EntityGraph ;
5
5
import org .springframework .data .jpa .repository .JpaRepository ;
6
6
7
7
import java .util .Optional ;
8
8
9
- public interface UserRepository extends JpaRepository <User , Long > {
9
+ public interface UserRepository extends JpaRepository <BasicUser , Long > {
10
10
11
11
@ EntityGraph (attributePaths = "permissions" )
12
- Optional <User > findDetailedByUsername (String username );
12
+ Optional <BasicUser > findDetailedByUsername (String username );
13
13
14
- Optional <User > findSummaryByUsername (String username );
14
+ Optional <BasicUser > findSummaryByUsername (String username );
15
15
16
- Optional <User > findByUsername (String username );
16
+ Optional <BasicUser > findByUsername (String username );
17
17
}
Original file line number Diff line number Diff line change 1
1
package com .baeldung .service ;
2
2
3
- import com .baeldung .model .User ;
3
+ import com .baeldung .model .BasicUser ;
4
4
import com .baeldung .repository .UserRepository ;
5
5
import org .springframework .stereotype .Service ;
6
6
import org .springframework .transaction .annotation .Transactional ;
@@ -18,7 +18,7 @@ public SimpleUserService(UserRepository userRepository) {
18
18
19
19
@ Override
20
20
@ Transactional (readOnly = true )
21
- public Optional <User > findOne (String username ) {
21
+ public Optional <BasicUser > findOne (String username ) {
22
22
return userRepository .findDetailedByUsername (username );
23
23
}
24
24
}
Original file line number Diff line number Diff line change 1
1
package com .baeldung .service ;
2
2
3
- import com .baeldung .model .User ;
3
+ import com .baeldung .model .BasicUser ;
4
4
5
5
import java .util .Optional ;
6
6
7
7
public interface UserService {
8
- Optional <User > findOne (String username );
8
+ Optional <BasicUser > findOne (String username );
9
9
}
Original file line number Diff line number Diff line change 1
1
package com .baeldung .web ;
2
2
3
- import com .baeldung .model .User ;
3
+ import com .baeldung .model .BasicUser ;
4
4
5
5
import java .util .Set ;
6
6
@@ -34,7 +34,7 @@ public void setPermissions(Set<String> permissions) {
34
34
this .permissions = permissions ;
35
35
}
36
36
37
- public static DetailedUserDto fromEntity (User user ) {
37
+ public static DetailedUserDto fromEntity (BasicUser user ) {
38
38
DetailedUserDto detailed = new DetailedUserDto ();
39
39
detailed .setId (user .getId ());
40
40
detailed .setUsername (user .getUsername ());
Original file line number Diff line number Diff line change 1
1
package com .baeldung .osiv ;
2
2
3
- import com .baeldung .model .User ;
3
+ import com .baeldung .model .BasicUser ;
4
4
import com .baeldung .repository .UserRepository ;
5
5
import org .junit .jupiter .api .AfterEach ;
6
6
import org .junit .jupiter .api .BeforeEach ;
@@ -32,7 +32,7 @@ class UserControllerIntegrationTest {
32
32
33
33
@ BeforeEach
34
34
void setUp () {
35
- User user = new User ();
35
+ BasicUser user = new BasicUser ();
36
36
user .setUsername ("root" );
37
37
user .setPermissions (new HashSet <>(Arrays .asList ("PERM_READ" , "PERM_WRITE" )));
38
38
You can’t perform that action at this time.
0 commit comments