[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[eclipselink-users] [Newbie] Problems with createNativeQuery
|
Hi
Starting my first EclipseLink persistence project. I've created my database,
used the Eclipse "create Entities from database" tool and started with my
first set of unit tests, which I've listed below. They all pass with the
exception of those that use entityManager.createNativeQuery() which fail and
the output from EclipseLInk suggests that the software thinks that the
primary key is null. Anyone got any ideas?
@Test
public void listPlatforms() {
String jpql = "select c from Platform c";
em.clear();
List<Platform> entities = (List) em.createQuery(jpql).getResultList();
assertEquals("List size:" , 9 , entities.size());
assertEquals("Id", 8, entities.get(7).getId());
}
@Test
public void listPlatformsNative() {
em.clear();
String jpql = "select * from Platform";
List<Platform> entities = (List)
em.createNativeQuery(jpql,Platform.class).getResultList();
assertEquals("List size:" , 9 , entities.size());
assertEquals("Id", 8, entities.get(7).getId());
}
@Test
public void getPlatformById() {
em.clear();
Platform platform = (Platform) em.find(Platform.class, 8);
assertNotNull(platform);
assertEquals("PlatformName", "record8", platform.getPlatformName());
assertEquals("Id",8,platform.getId());
}
@Test
public void getPlatformByQueryById() {
em.clear();
String jpql = "Select c from Platform c where c.id=8";
Platform platform = (Platform) em.createQuery(jpql).getSingleResult();
assertNotNull(platform);
assertEquals("PlatformName", "record8", platform.getPlatformName());
assertEquals("Id",8,platform.getId());
}
@Test
public void getPlatformByNativeQueryById() {
em.clear();
String jpql = "Select * from Platform where id=8";
Platform platform = (Platform)
em.createNativeQuery(jpql,Platform.class).getSingleResult();
assertNotNull(platform);
assertEquals("PlatformName", "record8", platform.getPlatformName());
assertEquals("Id",8,platform.getId());
}
}
--
View this message in context: http://www.nabble.com/-Newbie--Problems-with-createNativeQuery-tp25362312p25362312.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.