提交 5bf5a785 编写于 作者: C Calvin

Fix JPA problem

上级 7a230ae1
package org.springside.examples.miniweb.dao.account;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.metamodel.EntityType;
import javax.persistence.metamodel.Metamodel;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springside.modules.test.data.Fixtures;
import org.springside.modules.test.spring.SpringTxTestCase;
@ContextConfiguration(locations = { "/applicationContext.xml" })
@TransactionConfiguration()
public class JpaMappingTest extends SpringTxTestCase {
private static Logger logger = LoggerFactory.getLogger(JpaMappingTest.class);
@PersistenceContext
private EntityManager entityManager;
@Test
public void allClassMapping() throws Exception {
Fixtures.reloadAllTable(dataSource, "/data/sample-data.xml");
Metamodel model = entityManager.getEntityManagerFactory().getMetamodel();
for (EntityType entityType : model.getEntities()) {
String entityName = entityType.getName();
entityManager.createQuery("select o from " + entityName + " o").getFirstResult();
logger.info("ok: " + entityName);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册