|
From: <gca...@us...> - 2010-05-09 17:10:32
|
Revision: 2373
http://openutils.svn.sourceforge.net/openutils/?rev=2373&view=rev
Author: gcatania
Date: 2010-05-09 17:10:25 +0000 (Sun, 09 May 2010)
Log Message:
-----------
adding barebone hsqldb test environment, some entities for BSHD-7
Modified Paths:
--------------
trunk/openutils-bshd5/pom.xml
Added Paths:
-----------
trunk/openutils-bshd5/src/test/java/it/
trunk/openutils-bshd5/src/test/java/it/openutils/
trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/
trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/
trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/HibernateDAOTest.java
trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/dao/
trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/dao/PersonDAO.java
trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/
trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Address.java
trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Chance.java
trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/FantasticThing.java
trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/FullName.java
trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Person.java
trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Title.java
trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Wish.java
trunk/openutils-bshd5/src/test/resources/
trunk/openutils-bshd5/src/test/resources/hibernate.cfg.xml
trunk/openutils-bshd5/src/test/resources/spring-tests.xml
Modified: trunk/openutils-bshd5/pom.xml
===================================================================
--- trunk/openutils-bshd5/pom.xml 2010-05-09 16:53:04 UTC (rev 2372)
+++ trunk/openutils-bshd5/pom.xml 2010-05-09 17:10:25 UTC (rev 2373)
@@ -137,8 +137,68 @@
<artifactId>javassist</artifactId>
<version>3.4.GA</version>
</dependency>
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <version>1.2.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${spring.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-aspects</artifactId>
+ <version>${spring.version}</version>
+ <scope>test</scope>
+ </dependency>
+ -->
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>5.7</version>
+ <classifier>jdk15</classifier>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-annotations</artifactId>
+ <version>3.4.0.GA</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>avalon-framework</groupId>
+ <artifactId>avalon-framework</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>logkit</groupId>
+ <artifactId>logkit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.1</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<properties>
<spring.version>3.0.0.RELEASE</spring.version>
</properties>
-</project>
\ No newline at end of file
+</project>
Added: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/HibernateDAOTest.java
===================================================================
--- trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/HibernateDAOTest.java (rev 0)
+++ trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/HibernateDAOTest.java 2010-05-09 17:10:25 UTC (rev 2373)
@@ -0,0 +1,96 @@
+/**
+ *
+ * openutils base Spring-Hibernate DAO for java 5.0 (http://www.openmindlab.com/lab/products/bshd5.html)
+ *
+ * Copyright(C) null-2010, Openmind S.r.l. http://www.openmindonline.it
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl-2.1.html
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package it.openutils.hibernate.test;
+
+import it.openutils.hibernate.test.dao.PersonDAO;
+import it.openutils.hibernate.test.model.Address;
+import it.openutils.hibernate.test.model.FullName;
+import it.openutils.hibernate.test.model.Person;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+
+/**
+ * @author gcatania
+ */
+@ContextConfiguration(locations = "/spring-tests.xml")
+public class HibernateDAOTest extends AbstractTestNGSpringContextTests
+{
+
+ @Autowired
+ private PersonDAO personDAO;
+
+ private Person fifteenYearsOld()
+ {
+ return new Person(
+ new FullName("Troy", "Jones"),
+ 15,
+ new Address("Long road", 15, "Smalltown", "MI", 14352),
+ null);
+ }
+
+ /**
+ * basic save/evict/get test.
+ */
+ @Test
+ public void testSaveAndRetrievePerson()
+ {
+ Person person = fifteenYearsOld();
+ Long savedId = personDAO.save(person);
+ Assert.assertNotNull(savedId);
+ Long personId = person.getId();
+ Assert.assertEquals(savedId, personId);
+ personDAO.evict(person);
+ Person savedPerson = personDAO.get(personId);
+ Assert.assertEquals(person, savedPerson);
+ }
+
+ /**
+ * fails because of BSHD-5
+ */
+ @Test(enabled = false)
+ public void testFindFilteredFirst()
+ {
+ personDAO.save(fifteenYearsOld());
+ List<Person> found = personDAO.findFiltered(new Person(new FullName(null, "Jones"), null, null, null));
+ Assert.assertNotNull(found);
+ if (found.size() == 0)
+ {
+ Assert.fail("No persons found");
+ }
+ for (Person p : found)
+ {
+ System.out.println(p.toString());
+ }
+ }
+
+}
Property changes on: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/HibernateDAOTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/dao/PersonDAO.java
===================================================================
--- trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/dao/PersonDAO.java (rev 0)
+++ trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/dao/PersonDAO.java 2010-05-09 17:10:25 UTC (rev 2373)
@@ -0,0 +1,36 @@
+/**
+ *
+ */
+package it.openutils.hibernate.test.dao;
+
+import it.openutils.dao.hibernate.HibernateDAO;
+import it.openutils.dao.hibernate.HibernateDAOImpl;
+import it.openutils.hibernate.test.model.Person;
+
+import org.hibernate.SessionFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Repository;
+
+
+/**
+ * @author gcatania
+ */
+public interface PersonDAO extends HibernateDAO<Person, Long>
+{
+
+ /**
+ * @author gcatania
+ */
+ @Repository("personDAO")
+ class PersonDAOImpl extends HibernateDAOImpl<Person, Long> implements PersonDAO
+ {
+
+ @Autowired
+ public PersonDAOImpl(SessionFactory factory)
+ {
+ super(Person.class);
+ setSessionFactory(factory);
+ }
+ }
+
+}
Property changes on: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/dao/PersonDAO.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Address.java
===================================================================
--- trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Address.java (rev 0)
+++ trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Address.java 2010-05-09 17:10:25 UTC (rev 2373)
@@ -0,0 +1,274 @@
+/**
+ *
+ */
+package it.openutils.hibernate.test.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+
+/**
+ * @author gcatania
+ */
+@Entity
+public class Address
+{
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long id;
+
+ @Column(nullable = false, length = 50)
+ private String street;
+
+ @Column(nullable = false, scale = 4)
+ private Integer no;
+
+ @Column(nullable = false, length = 50)
+ private String city;
+
+ @Column(nullable = false, length = 2)
+ private String county;
+
+ @Column(nullable = false, scale = 5)
+ private Integer zipCode;
+
+ public Address()
+ {
+ }
+
+ public Address(String street, Integer no, String city, String county, Integer zipCode)
+ {
+ this.street = street;
+ this.no = no;
+ this.city = city;
+ this.county = county;
+ this.zipCode = zipCode;
+ }
+
+ /**
+ * @return the id
+ */
+ public Long getId()
+ {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ /**
+ * @return the street
+ */
+ public String getStreet()
+ {
+ return street;
+ }
+
+ /**
+ * @param street the street to set
+ */
+ public void setStreet(String street)
+ {
+ this.street = street;
+ }
+
+ /**
+ * @return the no
+ */
+ public Integer getNo()
+ {
+ return no;
+ }
+
+ /**
+ * @param no the no to set
+ */
+ public void setNo(Integer no)
+ {
+ this.no = no;
+ }
+
+ /**
+ * @return the city
+ */
+ public String getCity()
+ {
+ return city;
+ }
+
+ /**
+ * @param city the city to set
+ */
+ public void setCity(String city)
+ {
+ this.city = city;
+ }
+
+ /**
+ * @return the county
+ */
+ public String getCounty()
+ {
+ return county;
+ }
+
+ /**
+ * @param county the county to set
+ */
+ public void setCounty(String county)
+ {
+ this.county = county;
+ }
+
+ /**
+ * @return the zipCode
+ */
+ public Integer getZipCode()
+ {
+ return zipCode;
+ }
+
+ /**
+ * @param zipCode the zipCode to set
+ */
+ public void setZipCode(Integer zipCode)
+ {
+ this.zipCode = zipCode;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((city == null) ? 0 : city.hashCode());
+ result = prime * result + ((county == null) ? 0 : county.hashCode());
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ result = prime * result + ((no == null) ? 0 : no.hashCode());
+ result = prime * result + ((street == null) ? 0 : street.hashCode());
+ result = prime * result + ((zipCode == null) ? 0 : zipCode.hashCode());
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (obj == null)
+ {
+ return false;
+ }
+ if (getClass() != obj.getClass())
+ {
+ return false;
+ }
+ Address other = (Address) obj;
+ if (city == null)
+ {
+ if (other.city != null)
+ {
+ return false;
+ }
+ }
+ else if (!city.equals(other.city))
+ {
+ return false;
+ }
+ if (county == null)
+ {
+ if (other.county != null)
+ {
+ return false;
+ }
+ }
+ else if (!county.equals(other.county))
+ {
+ return false;
+ }
+ if (id == null)
+ {
+ if (other.id != null)
+ {
+ return false;
+ }
+ }
+ else if (!id.equals(other.id))
+ {
+ return false;
+ }
+ if (no == null)
+ {
+ if (other.no != null)
+ {
+ return false;
+ }
+ }
+ else if (!no.equals(other.no))
+ {
+ return false;
+ }
+ if (street == null)
+ {
+ if (other.street != null)
+ {
+ return false;
+ }
+ }
+ else if (!street.equals(other.street))
+ {
+ return false;
+ }
+ if (zipCode == null)
+ {
+ if (other.zipCode != null)
+ {
+ return false;
+ }
+ }
+ else if (!zipCode.equals(other.zipCode))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return "Address [city="
+ + city
+ + ", county="
+ + county
+ + ", id="
+ + id
+ + ", no="
+ + no
+ + ", street="
+ + street
+ + ", zipCode="
+ + zipCode
+ + "]";
+ }
+
+}
Property changes on: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Address.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Chance.java
===================================================================
--- trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Chance.java (rev 0)
+++ trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Chance.java 2010-05-09 17:10:25 UTC (rev 2373)
@@ -0,0 +1,13 @@
+/**
+ *
+ */
+package it.openutils.hibernate.test.model;
+
+/**
+ * @author gcatania
+ */
+public enum Chance {
+
+ /** chance. */
+ TOTALLY_REMOTE, VAGUELY_POSSIBLE, QUITE_POSSIBLE, CAKEWALK_EASY
+}
Property changes on: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Chance.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/FantasticThing.java
===================================================================
--- trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/FantasticThing.java (rev 0)
+++ trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/FantasticThing.java 2010-05-09 17:10:25 UTC (rev 2373)
@@ -0,0 +1,214 @@
+/**
+ *
+ * openutils base Spring-Hibernate DAO for java 5.0 (http://www.openmindlab.com/lab/products/bshd5.html)
+ *
+ * Copyright(C) null-2010, Openmind S.r.l. http://www.openmindonline.it
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl-2.1.html
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package it.openutils.hibernate.test.model;
+
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+
+
+/**
+ * @author gcatania
+ */
+@Entity
+public class FantasticThing
+{
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long id;
+
+ private String thingName;
+
+ private Chance chanceOfAchievement;
+
+ @ManyToMany(mappedBy = "objectsOfWish", cascade = CascadeType.ALL)
+ private Set<Wish> wishes;
+
+ public FantasticThing()
+ {
+ }
+
+ public FantasticThing(String thingName, Chance chanceOfAchievement)
+ {
+ this.thingName = thingName;
+ this.chanceOfAchievement = chanceOfAchievement;
+ }
+
+ /**
+ * @return the id
+ */
+ public Long getId()
+ {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ /**
+ * @return the thingName
+ */
+ public String getThingName()
+ {
+ return thingName;
+ }
+
+ /**
+ * @param thingName the thingName to set
+ */
+ public void setThingName(String thingName)
+ {
+ this.thingName = thingName;
+ }
+
+ /**
+ * @return the chanceOfAchievement
+ */
+ public Chance getChanceOfAchievement()
+ {
+ return chanceOfAchievement;
+ }
+
+ /**
+ * @param chanceOfAchievement the chanceOfAchievement to set
+ */
+ public void setChanceOfAchievement(Chance chanceOfAchievement)
+ {
+ this.chanceOfAchievement = chanceOfAchievement;
+ }
+
+ /**
+ * @return the wishes
+ */
+ public Set<Wish> getWishes()
+ {
+ return wishes;
+ }
+
+ /**
+ * @param wishes the wishes to set
+ */
+ public void setWishes(Set<Wish> wishes)
+ {
+ this.wishes = wishes;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((chanceOfAchievement == null) ? 0 : chanceOfAchievement.hashCode());
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ result = prime * result + ((thingName == null) ? 0 : thingName.hashCode());
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (obj == null)
+ {
+ return false;
+ }
+ if (getClass() != obj.getClass())
+ {
+ return false;
+ }
+ FantasticThing other = (FantasticThing) obj;
+ if (chanceOfAchievement == null)
+ {
+ if (other.chanceOfAchievement != null)
+ {
+ return false;
+ }
+ }
+ else if (!chanceOfAchievement.equals(other.chanceOfAchievement))
+ {
+ return false;
+ }
+ if (id == null)
+ {
+ if (other.id != null)
+ {
+ return false;
+ }
+ }
+ else if (!id.equals(other.id))
+ {
+ return false;
+ }
+ if (thingName == null)
+ {
+ if (other.thingName != null)
+ {
+ return false;
+ }
+ }
+ else if (!thingName.equals(other.thingName))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return "FantasticThing [chanceOfAchievement="
+ + chanceOfAchievement
+ + ", id="
+ + id
+ + ", thingName="
+ + thingName
+ + "]";
+ }
+
+}
Property changes on: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/FantasticThing.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/FullName.java
===================================================================
--- trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/FullName.java (rev 0)
+++ trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/FullName.java 2010-05-09 17:10:25 UTC (rev 2373)
@@ -0,0 +1,161 @@
+/**
+ *
+ */
+package it.openutils.hibernate.test.model;
+
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+
+
+/**
+ * @author gcatania
+ */
+@Embeddable
+public class FullName
+{
+
+ private Title title;
+
+ @Column(nullable = false)
+ private String givenName;
+
+ @Column(nullable = false)
+ private String familyName;
+
+ public FullName()
+ {
+ }
+
+ public FullName(String givenName, String familyName)
+ {
+ this.givenName = givenName;
+ this.familyName = familyName;
+ }
+
+ /**
+ * @return the title
+ */
+ public Title getTitle()
+ {
+ return title;
+ }
+
+ /**
+ * @param title the title to set
+ */
+ public void setTitle(Title title)
+ {
+ this.title = title;
+ }
+
+ /**
+ * @return the givenName
+ */
+ public String getGivenName()
+ {
+ return givenName;
+ }
+
+ /**
+ * @param givenName the givenName to set
+ */
+ public void setGivenName(String givenName)
+ {
+ this.givenName = givenName;
+ }
+
+ /**
+ * @return the familyName
+ */
+ public String getFamilyName()
+ {
+ return familyName;
+ }
+
+ /**
+ * @param familyName the familyName to set
+ */
+ public void setFamilyName(String familyName)
+ {
+ this.familyName = familyName;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((familyName == null) ? 0 : familyName.hashCode());
+ result = prime * result + ((givenName == null) ? 0 : givenName.hashCode());
+ result = prime * result + ((title == null) ? 0 : title.hashCode());
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (obj == null)
+ {
+ return false;
+ }
+ if (getClass() != obj.getClass())
+ {
+ return false;
+ }
+ FullName other = (FullName) obj;
+ if (familyName == null)
+ {
+ if (other.familyName != null)
+ {
+ return false;
+ }
+ }
+ else if (!familyName.equals(other.familyName))
+ {
+ return false;
+ }
+ if (givenName == null)
+ {
+ if (other.givenName != null)
+ {
+ return false;
+ }
+ }
+ else if (!givenName.equals(other.givenName))
+ {
+ return false;
+ }
+ if (title == null)
+ {
+ if (other.title != null)
+ {
+ return false;
+ }
+ }
+ else if (!title.equals(other.title))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return "FullName [familyName=" + familyName + ", givenName=" + givenName + ", title=" + title + "]";
+ }
+
+}
Property changes on: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/FullName.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Person.java
===================================================================
--- trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Person.java (rev 0)
+++ trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Person.java 2010-05-09 17:10:25 UTC (rev 2373)
@@ -0,0 +1,284 @@
+/**
+ *
+ * openutils base Spring-Hibernate DAO for java 5.0 (http://www.openmindlab.com/lab/products/bshd5.html)
+ *
+ * Copyright(C) null-2010, Openmind S.r.l. http://www.openmindonline.it
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl-2.1.html
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package it.openutils.hibernate.test.model;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToOne;
+
+
+/**
+ * @author gcatania
+ */
+@Entity
+public class Person
+{
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long id;
+
+ @Embedded
+ private FullName name;
+
+ @Column(nullable = false, scale = 3)
+ private Integer age;
+
+ @ManyToOne(fetch = FetchType.EAGER, optional = false, cascade = CascadeType.ALL)
+ private Address currentAddress;
+
+ @ManyToOne(cascade = CascadeType.ALL)
+ private Address fiscalAddress;
+
+ @OneToOne
+ private Wish wish;
+
+ public Person()
+ {
+ }
+
+ public Person(FullName name, Integer age, Address currentAddress, Address fiscalAddress)
+ {
+ this.name = name;
+ this.age = age;
+ this.currentAddress = currentAddress;
+ this.fiscalAddress = fiscalAddress;
+ }
+
+ /**
+ * @return the id
+ */
+ public Long getId()
+ {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ /**
+ * @return the name
+ */
+ public FullName getName()
+ {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(FullName name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * @return the currentAddress
+ */
+ public Address getCurrentAddress()
+ {
+ return currentAddress;
+ }
+
+ /**
+ * @param currentAddress the currentAddress to set
+ */
+ public void setCurrentAddress(Address currentAddress)
+ {
+ this.currentAddress = currentAddress;
+ }
+
+ /**
+ * @return the fiscalAddress
+ */
+ public Address getFiscalAddress()
+ {
+ return fiscalAddress;
+ }
+
+ /**
+ * @param fiscalAddress the fiscalAddress to set
+ */
+ public void setFiscalAddress(Address fiscalAddress)
+ {
+ this.fiscalAddress = fiscalAddress;
+ }
+
+ /**
+ * @return the wish
+ */
+ public Wish getWish()
+ {
+ return wish;
+ }
+
+ /**
+ * @param wish the wish to set
+ */
+ public void setWish(Wish wish)
+ {
+ this.wish = wish;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((age == null) ? 0 : age);
+ result = prime * result + ((currentAddress == null) ? 0 : currentAddress.hashCode());
+ result = prime * result + ((fiscalAddress == null) ? 0 : fiscalAddress.hashCode());
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((wish == null) ? 0 : wish.hashCode());
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (obj == null)
+ {
+ return false;
+ }
+ if (getClass() != obj.getClass())
+ {
+ return false;
+ }
+ Person other = (Person) obj;
+ if (age == null)
+ {
+ if (other.age != null)
+ {
+ return false;
+ }
+ }
+ else if (!age.equals(other.age))
+ {
+ return false;
+ }
+ if (currentAddress == null)
+ {
+ if (other.currentAddress != null)
+ {
+ return false;
+ }
+ }
+ else if (!currentAddress.equals(other.currentAddress))
+ {
+ return false;
+ }
+ if (fiscalAddress == null)
+ {
+ if (other.fiscalAddress != null)
+ {
+ return false;
+ }
+ }
+ else if (!fiscalAddress.equals(other.fiscalAddress))
+ {
+ return false;
+ }
+ if (id == null)
+ {
+ if (other.id != null)
+ {
+ return false;
+ }
+ }
+ else if (!id.equals(other.id))
+ {
+ return false;
+ }
+ if (name == null)
+ {
+ if (other.name != null)
+ {
+ return false;
+ }
+ }
+ else if (!name.equals(other.name))
+ {
+ return false;
+ }
+ if (wish == null)
+ {
+ if (other.wish != null)
+ {
+ return false;
+ }
+ }
+ else if (!wish.equals(other.wish))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return "Person [age="
+ + age
+ + ", currentAddress="
+ + currentAddress
+ + ", fiscalAddress="
+ + fiscalAddress
+ + ", id="
+ + id
+ + ", name="
+ + name
+ + ", wish="
+ + wish
+ + "]";
+ }
+
+}
Property changes on: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Person.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Title.java
===================================================================
--- trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Title.java (rev 0)
+++ trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Title.java 2010-05-09 17:10:25 UTC (rev 2373)
@@ -0,0 +1,14 @@
+/**
+ *
+ */
+package it.openutils.hibernate.test.model;
+
+/**
+ * @author gcatania
+ */
+public enum Title {
+
+ /** male, female titles */
+ MR, MRS
+
+}
Property changes on: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Title.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Wish.java
===================================================================
--- trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Wish.java (rev 0)
+++ trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Wish.java 2010-05-09 17:10:25 UTC (rev 2373)
@@ -0,0 +1,238 @@
+/**
+ *
+ */
+package it.openutils.hibernate.test.model;
+
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+import javax.persistence.OneToOne;
+import javax.persistence.Transient;
+
+
+/**
+ * @author gcatania
+ */
+@Entity
+public class Wish
+{
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long id;
+
+ @OneToOne(mappedBy = "wish", optional = false, cascade = CascadeType.ALL)
+ private Person person;
+
+ @Column(nullable = false)
+ private String reason;
+
+ @ManyToMany(cascade = CascadeType.ALL)
+ private Set<FantasticThing> objectsOfWish;
+
+ @Transient
+ private Integer objectCount;
+
+ public Wish()
+ {
+ }
+
+ public Wish(Person person, String reason)
+ {
+ this.person = person;
+ this.reason = reason;
+ }
+
+ /**
+ * @return the id
+ */
+ public Long getId()
+ {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ /**
+ * @return the person
+ */
+ public Person getPerson()
+ {
+ return person;
+ }
+
+ /**
+ * @param person the person to set
+ */
+ public void setPerson(Person person)
+ {
+ this.person = person;
+ }
+
+ /**
+ * @return the reason
+ */
+ public String getReason()
+ {
+ return reason;
+ }
+
+ /**
+ * @param reason the reason to set
+ */
+ public void setReason(String reason)
+ {
+ this.reason = reason;
+ }
+
+ /**
+ * @return the objectsOfWish
+ */
+ public Set<FantasticThing> getObjectsOfWish()
+ {
+ return objectsOfWish;
+ }
+
+ /**
+ * @param objectsOfWish the objectsOfWish to set
+ */
+ public void setObjectsOfWish(Set<FantasticThing> objectsOfWish)
+ {
+ this.objectsOfWish = objectsOfWish;
+ }
+
+ /**
+ * @return the objectCount
+ */
+ public Integer getObjectCount()
+ {
+ if (objectCount == null)
+ {
+ objectCount = objectsOfWish.size();
+ }
+ return objectCount;
+ }
+
+ /**
+ * @param objectCount the objectCount to set
+ */
+ public void setObjectCount(Integer objectCount)
+ {
+ if (objectCount != null && objectCount != objectsOfWish.size())
+ {
+ throw new IllegalArgumentException();
+ }
+ this.objectCount = objectCount;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ result = prime * result + ((objectCount == null) ? 0 : objectCount.hashCode());
+ result = prime * result + ((objectsOfWish == null) ? 0 : objectsOfWish.hashCode());
+ result = prime * result + ((reason == null) ? 0 : reason.hashCode());
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (obj == null)
+ {
+ return false;
+ }
+ if (getClass() != obj.getClass())
+ {
+ return false;
+ }
+ Wish other = (Wish) obj;
+ if (id == null)
+ {
+ if (other.id != null)
+ {
+ return false;
+ }
+ }
+ else if (!id.equals(other.id))
+ {
+ return false;
+ }
+ if (objectCount == null)
+ {
+ if (other.objectCount != null)
+ {
+ return false;
+ }
+ }
+ else if (!objectCount.equals(other.objectCount))
+ {
+ return false;
+ }
+ if (objectsOfWish == null)
+ {
+ if (other.objectsOfWish != null)
+ {
+ return false;
+ }
+ }
+ else if (!objectsOfWish.equals(other.objectsOfWish))
+ {
+ return false;
+ }
+ if (reason == null)
+ {
+ if (other.reason != null)
+ {
+ return false;
+ }
+ }
+ else if (!reason.equals(other.reason))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return "Wish [id="
+ + id
+ + ", objectCount="
+ + objectCount
+ + ", objectsOfWish="
+ + objectsOfWish
+ + ", reason="
+ + reason
+ + "]";
+ }
+
+}
Property changes on: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Wish.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/openutils-bshd5/src/test/resources/hibernate.cfg.xml
===================================================================
--- trunk/openutils-bshd5/src/test/resources/hibernate.cfg.xml (rev 0)
+++ trunk/openutils-bshd5/src/test/resources/hibernate.cfg.xml 2010-05-09 17:10:25 UTC (rev 2373)
@@ -0,0 +1,12 @@
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+<hibernate-configuration>
+ <session-factory>
+ <mapping class="it.openutils.hibernate.test.model.Address" />
+ <mapping class="it.openutils.hibernate.test.model.FantasticThing" />
+ <mapping class="it.openutils.hibernate.test.model.FullName" />
+ <mapping class="it.openutils.hibernate.test.model.Person" />
+ <mapping class="it.openutils.hibernate.test.model.Wish" />
+ </session-factory>
+</hibernate-configuration>
\ No newline at end of file
Property changes on: trunk/openutils-bshd5/src/test/resources/hibernate.cfg.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/openutils-bshd5/src/test/resources/spring-tests.xml
===================================================================
--- trunk/openutils-bshd5/src/test/resources/spring-tests.xml (rev 0)
+++ trunk/openutils-bshd5/src/test/resources/spring-tests.xml 2010-05-09 17:10:25 UTC (rev 2373)
@@ -0,0 +1,31 @@
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/aop
+ http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-2.5.xsd">
+ <context:annotation-config />
+ <context:component-scan base-package="it.openutils.hibernate.test" />
+ <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
+ <property name="url" value="jdbc:hsqldb:mem:daotest" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </bean>
+ <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
+ <property name="dataSource" ref="dataSource" />
+ <property name="configLocation" value="classpath:hibernate.cfg.xml" />
+ <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />
+ <property name="hibernateProperties">
+ <props>
+ <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
+ <prop key="hibernate.show_sql">true</prop>
+ <prop key="hibernate.hbm2ddl.auto">create-drop</prop>
+ </props>
+ </property>
+ </bean>
+</beans>
\ No newline at end of file
Property changes on: trunk/openutils-bshd5/src/test/resources/spring-tests.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|