-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
plantuml-generator-util/src/test/java/de/elnarion/test/sequence/t0003jakarta/Movie.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package de.elnarion.test.sequence.t0003jakarta; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
|
||
@Entity | ||
@Table(name = "MOVIE") | ||
public class Movie { | ||
|
||
@Id | ||
private Long id; | ||
|
||
private String movieName; | ||
|
||
private Integer releaseYear; | ||
|
||
private String language; | ||
|
||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getMovieName() { | ||
return movieName; | ||
} | ||
|
||
public void setMovieName(String movieName) { | ||
this.movieName = movieName; | ||
} | ||
|
||
public Integer getReleaseYear() { | ||
return releaseYear; | ||
} | ||
|
||
public void setReleaseYear(Integer releaseYear) { | ||
this.releaseYear = releaseYear; | ||
} | ||
|
||
public String getLanguage() { | ||
return language; | ||
} | ||
|
||
public void setLanguage(String language) { | ||
this.language = language; | ||
} | ||
|
||
} |
65 changes: 65 additions & 0 deletions
65
plantuml-generator-util/src/test/java/de/elnarion/test/sequence/t0003jakarta/MovieDAO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package de.elnarion.test.sequence.t0003jakarta; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.persistence.EntityManager; | ||
import jakarta.persistence.PersistenceContext; | ||
|
||
public class MovieDAO { | ||
|
||
@PersistenceContext | ||
private | ||
EntityManager entityManager; | ||
|
||
|
||
public void saveMovie(de.elnarion.test.sequence.t0003jakarta.Movie paramMovie) { | ||
EntityManager em = getEntityManager(); | ||
|
||
em.getTransaction().begin(); | ||
|
||
em.persist(paramMovie); | ||
em.getTransaction().commit(); | ||
} | ||
|
||
public de.elnarion.test.sequence.t0003jakarta.Movie getMovie(Long movieId) { | ||
EntityManager em = getEntityManager(); | ||
de.elnarion.test.sequence.t0003jakarta.Movie movie = em.find(de.elnarion.test.sequence.t0003jakarta.Movie.class, Long.valueOf(movieId)); | ||
em.detach(movie); | ||
return movie; | ||
} | ||
|
||
public void changeMovieLanguage(Long paramId, String paramLanguage) { | ||
EntityManager em = getEntityManager(); | ||
de.elnarion.test.sequence.t0003jakarta.Movie movie = getMovie(paramId); | ||
em.detach(movie); | ||
movie.setLanguage(paramLanguage); | ||
em.getTransaction().begin(); | ||
em.merge(movie); | ||
em.getTransaction().commit(); | ||
} | ||
|
||
public List<?> queryForMovies() { | ||
EntityManager em = getEntityManager(); | ||
List<?> movies = em.createQuery("SELECT movie from Movie movie where movie.language = ?1") | ||
.setParameter(1, "English") | ||
.getResultList(); | ||
return movies; | ||
} | ||
|
||
public void removeMovie() { | ||
EntityManager em = getEntityManager(); | ||
em.getTransaction().begin(); | ||
de.elnarion.test.sequence.t0003jakarta.Movie movie = em.find(de.elnarion.test.sequence.t0003jakarta.Movie.class, Long.valueOf(1L)); | ||
em.remove(movie); | ||
em.getTransaction().commit(); | ||
} | ||
|
||
public EntityManager getEntityManager() { | ||
return entityManager; | ||
} | ||
|
||
|
||
public void setEntityManager(EntityManager entityManager) { | ||
this.entityManager = entityManager; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...uml-generator-util/src/test/java/de/elnarion/test/sequence/t0003jakarta/MovieService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package de.elnarion.test.sequence.t0003jakarta; | ||
|
||
import de.elnarion.test.sequence.t0003.Movie; | ||
import de.elnarion.test.sequence.t0003.MovieDAO; | ||
|
||
public class MovieService { | ||
|
||
MovieDAO movieDAO; | ||
|
||
public void doSomeBusiness() { | ||
Movie movie = movieDAO.getMovie((long) 111); | ||
movie.setMovieName("asdfasdfasdf"); | ||
movieDAO.saveMovie(movie); | ||
} | ||
|
||
} |