|
@@ -3,7 +3,6 @@ package hello.dao;
|
|
import hello.model.World;
|
|
import hello.model.World;
|
|
|
|
|
|
import javax.persistence.EntityManager;
|
|
import javax.persistence.EntityManager;
|
|
-import javax.persistence.Query;
|
|
|
|
|
|
|
|
import com.google.inject.Inject;
|
|
import com.google.inject.Inject;
|
|
import com.google.inject.Provider;
|
|
import com.google.inject.Provider;
|
|
@@ -16,13 +15,7 @@ public class WorldDao {
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
public World get(int id) {
|
|
public World get(int id) {
|
|
-
|
|
|
|
EntityManager entityManager = entitiyManagerProvider.get();
|
|
EntityManager entityManager = entitiyManagerProvider.get();
|
|
-
|
|
|
|
- Query q = entityManager
|
|
|
|
- .createQuery("SELECT x FROM World x WHERE x.id = :idParam");
|
|
|
|
- World world = (World) q.setParameter("idParam", id).getSingleResult();
|
|
|
|
-
|
|
|
|
- return world;
|
|
|
|
|
|
+ return entityManager.find(World.class, id);
|
|
}
|
|
}
|
|
}
|
|
}
|