Last active
February 29, 2016 09:13
-
-
Save hodlbirb/e6c8a2a21ff579375414 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Main; | |
import Model.Person; | |
import javax.persistence.EntityManager; | |
import javax.persistence.EntityManagerFactory; | |
import javax.persistence.EntityTransaction; | |
import javax.persistence.Persistence; | |
public class Main { | |
public static void main(String[] args) { | |
Person person = new Person() { | |
{ | |
setFirstName("John"); | |
setLastName("Doe"); | |
} | |
}; | |
EntityManagerFactory emf = Persistence.createEntityManagerFactory("jpa"); | |
EntityManager entityManager = emf.createEntityManager(); | |
EntityTransaction tx = entityManager.getTransaction(); | |
tx.begin(); | |
entityManager.persist(person); | |
tx.commit(); | |
entityManager.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment