-
Notifications
You must be signed in to change notification settings - Fork 0
WK6 #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ivanmaker
wants to merge
1
commit into
master
Choose a base branch
from
WK6
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
WK6 #6
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 characters
| 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" /> | ||
| <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> | ||
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 characters
| 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> |
129 changes: 129 additions & 0 deletions
129
WK6/ORM_Example/src/main/java/com/origamisoftware/teach/advanced/model/Hobby.java
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 characters
| 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 + | ||
| '}'; | ||
| } | ||
| } |
133 changes: 133 additions & 0 deletions
133
WK6/ORM_Example/src/main/java/com/origamisoftware/teach/advanced/model/Person.java
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 characters
| 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 + | ||
| '}'; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.