Skip to content

Instantly share code, notes, and snippets.

@michaelkotor
Created August 25, 2025 08:06
Show Gist options
  • Select an option

  • Save michaelkotor/9e5c8db66440024d3e333b96d97c6e18 to your computer and use it in GitHub Desktop.

Select an option

Save michaelkotor/9e5c8db66440024d3e333b96d97c6e18 to your computer and use it in GitHub Desktop.
@Service
public class UserSrvc {
public UserRepository mySrvc;
public UserSrvc() {
this.mySrvc = new UserRepository();
}
public User doSmthngImportant(Long id) {
if (id == null) {
return null;
}
try {
return doDatabaseWork(id);
} catch (Exception e) {
}
return null;
}
@Transactional
private User doDatabaseWork(Long userID) {
System.out.println("Doing something very important");
User u = mySrvc.findById(userID).get();
u.setName("UpdatedName");
mySrvc.save(u);
return u;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment