Skip to content

Instantly share code, notes, and snippets.

@dsirotkin256
Last active February 29, 2016 09:13
Show Gist options
  • Select an option

  • Save dsirotkin256/e6c8a2a21ff579375414 to your computer and use it in GitHub Desktop.

Select an option

Save dsirotkin256/e6c8a2a21ff579375414 to your computer and use it in GitHub Desktop.
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();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment