BAEL-4507 - UserSocialMedia class added

This commit is contained in:
Anshul BANSAL 2020-09-12 06:30:35 +03:00
parent fe9f89ad96
commit bc36751276
3 changed files with 20 additions and 14 deletions

View File

@ -1,7 +1,5 @@
package com.baeldung.repositoryvsdaopattern;
import java.util.List;
public class User {
private Long id;
@ -10,8 +8,6 @@ public class User {
private String lastName;
private String email;
private List<Tweet> tweets;
public Long getId() {
return id;
}
@ -51,13 +47,5 @@ public class User {
public void setEmail(String email) {
this.email = email;
}
public List<Tweet> getTweets() {
return tweets;
}
public void setTweets(List<Tweet> tweets) {
this.tweets = tweets;
}
}

View File

@ -9,7 +9,7 @@ public class UserRepositoryImpl implements UserRepository {
@Override
public User get(Long id) {
User user = userDaoImpl.read(id);
UserSocialMedia user = (UserSocialMedia) userDaoImpl.read(id);
List<Tweet> tweets = tweetDaoImpl.fetchTweets(user.getEmail());
user.setTweets(tweets);
@ -34,7 +34,8 @@ public class UserRepositoryImpl implements UserRepository {
@Override
public List<Tweet> fetchTweets(User user) {
return null;
return tweetDaoImpl.fetchTweets(user.getEmail());
}
@Override

View File

@ -0,0 +1,17 @@
package com.baeldung.repositoryvsdaopattern;
import java.util.List;
public class UserSocialMedia extends User {
private List<Tweet> tweets;
public List<Tweet> getTweets() {
return tweets;
}
public void setTweets(List<Tweet> tweets) {
this.tweets = tweets;
}
}