Author: dgeraskov
Date: 2008-01-15 09:53:26 -0500 (Tue, 15 Jan 2008)
New Revision: 5703
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/Person.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/Task.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/Thing.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/db/User.hbm.xml
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/db/User.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/where/File.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/where/NumericTrueFalseType.java
Log:
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/Person.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/Person.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/Person.java 2008-01-15
14:53:26 UTC (rev 5703)
@@ -0,0 +1,43 @@
+//$Id$
+package mapping.version;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Person {
+ private String name;
+ private List things;
+ private List tasks;
+ private int version;
+
+ Person() {}
+ public Person(String name) {
+ this.name = name;
+ this.things = new ArrayList();
+ this.tasks = new ArrayList();
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public List getThings() {
+ return things;
+ }
+ public void setThings(List things) {
+ this.things = things;
+ }
+ public int getVersion() {
+ return version;
+ }
+ public void setVersion(int version) {
+ this.version = version;
+ }
+ public List getTasks() {
+ return tasks;
+ }
+ public void setTasks(List tasks) {
+ this.tasks = tasks;
+ }
+}
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/Person.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/Task.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/Task.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/Task.java 2008-01-15
14:53:26 UTC (rev 5703)
@@ -0,0 +1,33 @@
+//$Id$
+package mapping.version;
+
+public class Task {
+ private String description;
+ private Person person;
+ private int version;
+
+ public int getVersion() {
+ return version;
+ }
+ public void setVersion(int version) {
+ this.version = version;
+ }
+ Task() {}
+ public Task(String description, Person person) {
+ this.description = description;
+ this.person = person;
+ person.getTasks().add(this);
+ }
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+ public Person getPerson() {
+ return person;
+ }
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+}
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/Task.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/Thing.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/Thing.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/Thing.java 2008-01-15
14:53:26 UTC (rev 5703)
@@ -0,0 +1,40 @@
+//$Id$
+package mapping.version;
+
+public class Thing {
+ private String description;
+ private Person person;
+ private int version;
+ private String longDescription;
+
+ public int getVersion() {
+ return version;
+ }
+ public void setVersion(int version) {
+ this.version = version;
+ }
+ Thing() {}
+ public Thing(String description, Person person) {
+ this.description = description;
+ this.person = person;
+ person.getThings().add(this);
+ }
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+ public Person getPerson() {
+ return person;
+ }
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+ public String getLongDescription() {
+ return longDescription;
+ }
+ public void setLongDescription(String longDescription) {
+ this.longDescription = longDescription;
+ }
+}
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/Thing.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/db/User.hbm.xml
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/db/User.hbm.xml
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/db/User.hbm.xml 2008-01-15
14:53:26 UTC (rev 5703)
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+ Demonstrates how to control the optimistic locking behavior
+ of a collection (do changes to the collection result in
+ a version increment on the owning instance)
+ -->
+<hibernate-mapping
+ package="mapping.version.db">
+
+ <class name="User" table="db_vers_user">
+ <id name="id" column="user_id" type="long">
+ <generator class="native"/>
+ </id>
+ <timestamp name="timestamp" column="ts"
source="db"/>
+ <!--<version name="timestamp" column="ts"
type="org.hibernate.type.DbTimestampType"/>-->
+ <property name="username" column="user_name"
type="string" unique="true"/>
+ <set name="groups" table="db_vers_user_group"
batch-size="9" inverse="true" optimistic-lock="true"
lazy="true" cascade="none" >
+ <key column="user_id"/>
+ <many-to-many column="group_id" class="Group"
lazy="false" fetch="join" />
+ </set>
+ <set name="permissions" table="db_vers_user_perm"
batch-size="9" inverse="false" optimistic-lock="false"
lazy="true" cascade="none">
+ <key column="user_id"/>
+ <many-to-many column="perm_id" class="Permission"
lazy="false" fetch="join"/>
+ </set>
+ </class>
+
+ <class name="Group" table="db_vers_group">
+ <id name="id" column="group_id" type="long">
+ <generator class="native"/>
+ </id>
+ <timestamp name="timestamp" column="ts"
source="db"/>
+ <!--<version name="timestamp" column="ts"
type="org.hibernate.type.DbTimestampType"/>-->
+ <property name="name" column="name"
type="string" unique="true"/>
+ <set name="users" table="db_vers_user_group"
batch-size="9" inverse="false" lazy="true"
cascade="none" >
+ <key column="group_id"/>
+ <many-to-many column="user_id" class="User"
lazy="false" fetch="join" />
+ </set>
+ </class>
+
+ <class name="Permission" table="db_vers_permission">
+ <id name="id" column="perm_id" type="long">
+ <generator class="native"/>
+ </id>
+ <timestamp name="timestamp" column="ts"
source="db"/>
+ <!--<version name="timestamp" column="ts"
type="org.hibernate.type.DbTimestampType"/>-->
+ <property name="name" column="name"
type="string" unique="true"/>
+ <property name="context" column="ctx"
type="string"/>
+ <property name="access" column="priv"
type="string"/>
+ </class>
+
+</hibernate-mapping>
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/db/User.hbm.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/db/User.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/db/User.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/db/User.java 2008-01-15
14:53:26 UTC (rev 5703)
@@ -0,0 +1,65 @@
+// $Id$
+package mapping.version.db;
+
+import java.util.Set;
+import java.sql.Timestamp;
+
+/**
+ * Implementation of User.
+ *
+ * @author Steve Ebersole
+ */
+public class User {
+ private Long id;
+ private Timestamp timestamp;
+ private String username;
+ private Set groups;
+ private Set permissions;
+
+ public User() {
+ }
+
+ public User(String username) {
+ this.username = username;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Timestamp getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(Timestamp timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public Set getGroups() {
+ return groups;
+ }
+
+ public void setGroups(Set groups) {
+ this.groups = groups;
+ }
+
+ public Set getPermissions() {
+ return permissions;
+ }
+
+ public void setPermissions(Set permissions) {
+ this.permissions = permissions;
+ }
+}
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/version/db/User.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/where/File.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/where/File.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/where/File.java 2008-01-15
14:53:26 UTC (rev 5703)
@@ -0,0 +1,52 @@
+//$Id$
+package mapping.where;
+
+import java.util.Set;
+
+public class File {
+ private long id;
+ private String name;
+ private File parent;
+ private boolean deleted;
+ private Set children;
+
+ public Set getChildren() {
+ return children;
+ }
+ public void setChildren(Set children) {
+ this.children = children;
+ }
+
+ public File(String name, File parent) {
+ this.name = name;
+ this.parent = parent;
+ }
+
+ File() {}
+
+ public boolean isDeleted() {
+ return deleted;
+ }
+ public void setDeleted(boolean deleted) {
+ this.deleted = deleted;
+ }
+ public long getId() {
+ return id;
+ }
+ public void setId(long id) {
+ this.id = id;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public File getParent() {
+ return parent;
+ }
+ public void setParent(File parent) {
+ this.parent = parent;
+ }
+
+}
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/where/File.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/where/NumericTrueFalseType.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/where/NumericTrueFalseType.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/where/NumericTrueFalseType.java 2008-01-15
14:53:26 UTC (rev 5703)
@@ -0,0 +1,53 @@
+package mapping.where;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.PreparedStatement;
+import java.sql.Types;
+
+import org.hibernate.type.BooleanType;
+import org.hibernate.dialect.Dialect;
+
+/**
+ * Maps int db values to boolean java values. Zero is considered false; any
+ * non-zero value is considered true.
+ *
+ * @author Steve Ebersole
+ */
+public class NumericTrueFalseType extends BooleanType {
+
+ public Object get(ResultSet rs, String name) throws SQLException {
+ int value = rs.getInt( name );
+ if ( rs.wasNull() ) {
+ return getDefaultValue();
+ }
+ else if ( value == 0 ) {
+ return Boolean.FALSE;
+ }
+ else {
+ return Boolean.TRUE;
+ }
+ }
+
+ public void set(PreparedStatement st, Object value, int index) throws SQLException {
+ if ( value == null ) {
+ st.setNull( index, Types.INTEGER );
+ }
+ else {
+ boolean bool = ( ( Boolean ) value ).booleanValue();
+ st.setInt( index, bool ? 1 : 0 );
+ }
+ }
+
+ public String objectToSQLString(Object value, Dialect dialect) throws Exception {
+ return ( ( Boolean ) value ).booleanValue() ? "1" : "0";
+ }
+
+ public int sqlType() {
+ return Types.INTEGER;
+ }
+
+ public String getName() {
+ return "numeric_boolean";
+ }
+}
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/mapping/where/NumericTrueFalseType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native