日期:2014-05-18 浏览次数:20851 次
import java.util.Date;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import org.junit.BeforeClass;
import org.junit.Test;
import com.rz.openplat.crm.date.entity.PlUserMembergrade;
import com.rz.openplat.crm.date.entity.PlUserMembermanage;
public class PlUserMembermanageTest1 {
@BeforeClass
public static void setUpBeforeClass() throws Exception {
}
@Test
public void savePlUserMembermanage() {
EntityManagerFactory factory=Persistence.createEntityManagerFactory("myJPA");//-->sessionFactory
EntityManager manager=factory.createEntityManager(); //-->session
manager.getTransaction().begin();//-->开始事务
PlUserMembermanage ps = new PlUserMembermanage();
//ps.setBrithday(new Date("2012-03-06"));
ps.setMembername("天津饭");
ps.setMembersex("女");
ps.setMembertel("13568952369");
ps.setMemberremark("此会员平均一周买一次衣服");
ps.setMembermessage("开启");
//manager.persist(new Person("Hello World"));//new person 是新建状态
manager.persist(ps);
manager.getTransaction().commit();
manager.close();
factory.close();
}
}