Skip to content
Snippets Groups Projects
Commit 5f385c39 authored by Christopher Bohn's avatar Christopher Bohn :thinking:
Browse files

Corrections to work with CSE mysql server

- Added timezone info to URL to work with cse server
- Wrote README
parent 9cd47b00
No related branches found
No related tags found
No related merge requests found
# hibernate example
# Hibernate example
This code creates a simple one-to-many relationship between two tables and
populates them.
## Usage
Copy `src/main/resources/hibernate.cfg.xml-TEMPLATE` to
`src/main/resources/hibernate.cfg.xml` and replace *both* occurrences of
`USERNAME` with your CSE username, and replace `MYSQL_PASSWORD` with your
MySQL password.
The `main` method is in `edu.unl.cse.csce361.hibernate.FruitPopulator`.
\ No newline at end of file
......@@ -19,7 +19,7 @@ public class Fruit {
private Integer massInGrams;
@ManyToOne
@JoinColumn(name = "fruitSalad")
@JoinColumn
private FruitSalad salad;
public Fruit() { // 0-argument constructor
......
......@@ -48,9 +48,11 @@ public class FruitPopulator {
fruitSalad.addFruit(apple);
fruitSalad.addFruit(banana);
session.getTransaction().commit();
System.out.println();
System.out.println("Successfully populated tables.");
} catch (RuntimeException exception) {
session.getTransaction().rollback();
System.out.println();
System.out.println("Failed to populate tables. " + exception);
}
}
......
......@@ -11,7 +11,7 @@
com.mysql.jdbc.Driver
</property>
<property name="connection.url">
jdbc:mysql://cse.unl.edu/USERNAME
jdbc:mysql://cse.unl.edu/USERNAME?serverTimezone=America/Chicago
</property>
<property name="connection.username">
USERNAME
......@@ -32,6 +32,7 @@
<!-- Names the annotated entity class -->
<mapping class="edu.unl.cse.csce361.hibernate.Fruit"/>
<mapping class="edu.unl.cse.csce361.hibernate.FruitSalad"/>
</session-factory>
</hibernate-configuration>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment