Hello I have simple example of hibernate /jpa but not ablr to make it work. I do not get any exceptions in the log but the enetity is not saved I see the hibernate logging but not sure how to also add jpa logging in log4j.xml here is what I have in persitance.xml
<?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="myunit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.follett.efollett.coursetrack.ftp.domain.dto.Title</class> <properties> <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/> <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/test"/> <property name="hibernate.connection.username" value="root"/> <property name="hibernate.connection.password" value="root"/> <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.format_sql" value="true"/>
here is my code Title title= new Title(); title.setTitle("abc"); title.setMaterialId("abcde"); title.setAuthor("a");
EntityManagerFactory emf = Persistence.createEntityManagerFactory("myunit"); EntityManager manager = emf.createEntityManager(); manager.persist(title);
I am using java.persistance annotations in Title so I do not have a mapping file, the Title class has the default contructor also, the table is created in my sql test database but it has no priary key.
I would really appreciate your help
|