Last active
February 29, 2016 09:13
-
-
Save dsirotkin256/e6c8a2a21ff579375414 to your computer and use it in GitHub Desktop.
Revisions
-
dmitry-sirotkin revised this gist
Feb 29, 2016 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,6 @@ public static void main(String[] args) { Person person = new Person() { { setFirstName("John"); setLastName("Doe"); } -
dmitry-sirotkin revised this gist
Feb 29, 2016 . 1 changed file with 9 additions and 50 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,76 +1,35 @@ 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() { { setId(1); 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(); } } -
dmitry-sirotkin created this gist
Feb 29, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,76 @@ package Main; /** * Created by Eiger on 2/23/16. */ import Model.Person; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; import javax.persistence.Persistence; import java.io.IOException; public class Main extends Application { public static void main(String[] args) throws IOException { // HibernateConnector.getInstance().startSafeTransaction(new Person() { // { // setFirstName("Gloria"); // setLastName("Jeans"); // setDob(new Date()); // } // }); Person person = new Person() { { setId(1); setFirstName("Gloria"); setLastName("Jeans"); } }; // Configuration conf = new Configuration(); // conf.configure(); // // ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings( // conf.getProperties()).build(); // // SessionFactory sf = conf.buildSessionFactory(serviceRegistry); // // // Session s = sf.openSession(); // // System.out.println(sf.getAllClassMetadata()); // // s.beginTransaction(); // s.createQuery("UPDATE persons as p SET p.firstName = 'Hello' WHERE p.id = 1").executeUpdate(); // s.getTransaction().commit(); // sf.close(); EntityManagerFactory emf = Persistence.createEntityManagerFactory("jpa"); EntityManager entityManager = emf.createEntityManager(); EntityTransaction tx = entityManager.getTransaction(); tx.begin(); entityManager.persist(person); tx.commit(); entityManager.close(); // launch(args); } @Override public void start(Stage primaryStage) throws IOException { Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("View/VetDashboardView.fxml")); primaryStage.setScene(new Scene(root)); primaryStage.show(); } }