Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • gruppe-12/picturerama
1 result
Show changes
Commits on Source (2)
...@@ -61,7 +61,7 @@ public class PhotoContainer { ...@@ -61,7 +61,7 @@ public class PhotoContainer {
* @param photo a photo object * @param photo a photo object
*/ */
private void setupPhotoContainer(Photo photo) { private void setupPhotoContainer(Photo photo) {
image = new Image(photo.getUrl(), 150, 150, true, true); image = new Image(photo.getUrl(), 150, 150, true, true, true);
imageView = new ImageView(image); imageView = new ImageView(image);
photoButton = new Button(photo.getTitle(), imageView); photoButton = new Button(photo.getTitle(), imageView);
......
...@@ -132,7 +132,7 @@ public class PhotoViewer { ...@@ -132,7 +132,7 @@ public class PhotoViewer {
}); });
closeButton.setOnAction(e -> updateDatabaseAndClose()); closeButton.setOnAction(e -> updateDatabaseAndClose());
ImageView imageView = new ImageView(new Image(photo.getUrl(), 255, 255, true, true)); ImageView imageView = new ImageView(new Image(photo.getUrl(), 255, 255, true, true, true));
//Adding child nodes to parent nodes //Adding child nodes to parent nodes
AnchorPane.setLeftAnchor(imageInfoContainer, 10.0); AnchorPane.setLeftAnchor(imageInfoContainer, 10.0);
......
...@@ -17,6 +17,8 @@ public class Hibernate { ...@@ -17,6 +17,8 @@ public class Hibernate {
Persistence.createEntityManagerFactory("Database", getProperties()); Persistence.createEntityManagerFactory("Database", getProperties());
private static EntityManager em = ENTITY_MANAGER_FACTORY.createEntityManager(); private static EntityManager em = ENTITY_MANAGER_FACTORY.createEntityManager();
private Hibernate(){throw new IllegalStateException("Utility class");}
/** /**
* Sets up the password and username to the database * Sets up the password and username to the database
* @return a map with the password and username * @return a map with the password and username
...@@ -238,12 +240,17 @@ public class Hibernate { ...@@ -238,12 +240,17 @@ public class Hibernate {
} }
/** /**
* Gets entity manager * Gets entity manager or makes a new one if the connection is not open anymore
* *
* @return the entity manager * @return the entity manager
*/ */
public static EntityManager getEm() { public static EntityManager getEm() {
if(!em.isOpen()) {
em.close();
em = ENTITY_MANAGER_FACTORY.createEntityManager();
}
return em; return em;
} }
/** /**
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.connection.driver_class" value="com.mysql.cj.jdbc.Driver"/> <property name="hibernate.connection.driver_class" value="com.mysql.cj.jdbc.Driver"/>
<property name="hibernate.connection.url" value="jdbc:mysql://mysql-ait.stud.idi.ntnu.no:3306/olafros"/> <property name="hibernate.connection.url" value="jdbc:mysql://mysql-ait.stud.idi.ntnu.no:3306/olafros"/>
<property name="hibernate.connection.pool_size" value="5"/> <property name="hibernate.connection.pool_size" value="1"/>
</properties> </properties>
</persistence-unit> </persistence-unit>
</persistence> </persistence>
\ No newline at end of file