Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions WK6/ORM_Example/ORM_Example.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file should not be included.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, jar files should not be checked into the source tree.

<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.6" level="project" />
<orderEntry type="library" name="Maven: javax.validation:validation-api:1.0.0.GA" level="project" />
<orderEntry type="library" name="Maven: org.mockito:mockito-all:1.9.5" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.ibatis:ibatis-sqlmap:2.3.4.726" level="project" />
<orderEntry type="library" name="Maven: org.hibernate:hibernate-core:4.2.6.Final" level="project" />
<orderEntry type="library" name="Maven: antlr:antlr:2.7.7" level="project" />
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.1.0.GA" level="project" />
<orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" />
<orderEntry type="library" name="Maven: org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:1.0.1.Final" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.common:hibernate-commons-annotations:4.0.2.Final" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.15.0-GA" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final" level="project" />
</component>
</module>
87 changes: 87 additions & 0 deletions WK6/ORM_Example/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.origamisoftware.teach.effective</groupId>
<artifactId>ORM_Example</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>starter-app</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<compilerArgument>-Xlint</compilerArgument>
<encoding>${project.build.sourceEncoding}</encoding>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

<dependencies>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<type>jar</type>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>

<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4</version>
</dependency>

<dependency>
<groupId>org.apache.ibatis</groupId>
<artifactId>ibatis-sqlmap</artifactId>
<version>2.3.4.726</version>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.2.6.Final</version>
</dependency>

<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
package com.origamisoftware.teach.advanced.model;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;

/**
* Models the Hobby table
*/
@Entity
public class Hobby {

private int id;
private String name;
private String description;
private int minimumAge;

/**
* Primary Key - Unique ID for a particular row in the hobby table.
*
* @return an integer value
*/
@Id
@Column(name = "ID", nullable = false, insertable = true, updatable = true)
public int getId() {
return id;
}

/**
* Set the unique ID for a particular row in the hobby table.
* This method should not be called by client code. The value is managed in internally.
*
* @param id a unique value.
*/
public void setId(int id) {
this.id = id;
}

/**
* @return the name column as a String
*/
@Basic
@Column(name = "name", nullable = false, insertable = true, updatable = true, length = 256)
public String getName() {
return name;
}

/**
* Specify the person's name
*
* @param name a String value
*/
public void setName(String name) {
this.name = name;
}

/**
*
* @return the value of the description column as a String
*/
@Basic
@Column(name = "description", nullable = false, insertable = true, updatable = true, length = 2056)
public String getDescription() {
return description;
}

/**
* Specify the Hobby's description
*
* @param description a String value
*/
public void setDescription(String description) {
this.description = description;
}

/**
* The recommended age for the hobby, an int value
* @return the value of the minimum_age column as an int value
*/
@Basic
@Column(name = "minimum_age", nullable = false, insertable = true, updatable = true)
public int getMinimumAge() {
return minimumAge;
}

/**
* Specify the recommended age for the hobby
* @param minimumAge an int value
*/
public void setMinimumAge(int minimumAge) {
this.minimumAge = minimumAge;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

Hobby hobby = (Hobby) o;

if (id != hobby.id) return false;
if (minimumAge != hobby.minimumAge) return false;
if (description != null ? !description.equals(hobby.description) : hobby.description != null)
return false;
if (name != null ? !name.equals(hobby.name) : hobby.name != null) return false;

return true;
}

@Override
public int hashCode() {
int result = id;
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (description != null ? description.hashCode() : 0);
result = 31 * result + minimumAge;
return result;
}

@Override
public String toString() {
return "Hobby{" +
"id=" + id +
", name='" + name + '\'' +
", description='" + description + '\'' +
", minimumAge=" + minimumAge +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
package com.origamisoftware.teach.advanced.model;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.sql.Timestamp;

/**
* Models the Person table
*/
@Entity
@Table(name="person")
public class Person {

private int id;
private String firstName;
private String lastName;
private Timestamp birthDate;

/**
* Primary Key - Unique ID for a particular row in the person table.
*
* @return an integer value
*/
@Id
@Column(name = "ID", nullable = false, insertable = true, updatable = true)
public int getId() {
return id;
}

/**
* Set the unique ID for a particular row in the person table.
* This method should not be called by client code. The value is managed in internally.
*
* @param id a unique value.
*/
public void setId(int id) {
this.id = id;
}

/**
*
* @return the person's first name
*/
@Basic
@Column(name = "first_name", nullable = false, insertable = true, updatable = true, length = 256)
public String getFirstName() {
return firstName;
}

/**
* Specify the person's first name
* @param firstName a String value
*/
public void setFirstName(String firstName) {
this.firstName = firstName;
}

/**
*
* @return the person's last name
*/
@Basic
@Column(name = "last_name", nullable = false, insertable = true, updatable = true, length = 256)
public String getLastName() {
return lastName;
}

/**
* Specify the person's last name
* @param lastName a String value
*/
public void setLastName(String lastName) {
this.lastName = lastName;
}

/**
*
* @return the person's birthdate.
*/
@Basic
@Column(name = "birth_date", nullable = false, insertable = true, updatable = true)
public Timestamp getBirthDate() {
return birthDate;
}

/**
* Specify the person's date of birth.
* @param birthDate the time the person was born.
*/
public void setBirthDate(Timestamp birthDate) {
this.birthDate = birthDate;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

Person person = (Person) o;

if (id != person.id) return false;
if (birthDate != null ? !birthDate.equals(person.birthDate) : person.birthDate != null)
return false;
if (firstName != null ? !firstName.equals(person.firstName) : person.firstName != null)
return false;
if (lastName != null ? !lastName.equals(person.lastName) : person.lastName != null)
return false;

return true;
}

@Override
public int hashCode() {
int result = id;
result = 31 * result + (firstName != null ? firstName.hashCode() : 0);
result = 31 * result + (lastName != null ? lastName.hashCode() : 0);
result = 31 * result + (birthDate != null ? birthDate.hashCode() : 0);
return result;
}

@Override
public String toString() {
return "Person{" +
"id=" + id +
", firstName='" + firstName + '\'' +
", lastName='" + lastName + '\'' +
", birthDate=" + birthDate +
'}';
}
}
Loading