Author: stliu
Date: 2010-01-27 09:55:49 -0500 (Wed, 27 Jan 2010)
New Revision: 18647
Added:
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/BaseEntity.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/Device.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/DeviceGroupConfig.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/HHH4851Test.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/Hardware.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/ManagedDevice.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/Owner.java
Modified:
annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/OneToOneSecondPass.java
Log:
JBPAPP-3565 HHH-4851 OneToOneSecondPass Metadata is mistakenly interpreted
Modified:
annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/OneToOneSecondPass.java
===================================================================
---
annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/OneToOneSecondPass.java 2010-01-27
14:54:18 UTC (rev 18646)
+++
annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/OneToOneSecondPass.java 2010-01-27
14:55:49 UTC (rev 18647)
@@ -169,8 +169,9 @@
Iterator it = otherSide.getJoinIterator();
Join otherSideJoin = null;
while ( it.hasNext() ) {
- otherSideJoin = (Join) it.next();
- if ( otherSideJoin.containsProperty( otherSideProperty ) ) {
+ Join otherSideJoinValue = (Join) it.next();
+ if (otherSideJoinValue.containsProperty(otherSideProperty)) {
+ otherSideJoin = otherSideJoinValue;
break;
}
}
Added:
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/BaseEntity.java
===================================================================
---
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/BaseEntity.java
(rev 0)
+++
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/BaseEntity.java 2010-01-27
14:55:49 UTC (rev 18647)
@@ -0,0 +1,46 @@
+package org.hibernate.test.annotations.onetoone.hhh4851;
+
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.MappedSuperclass;
+import javax.persistence.Version;
+
+@MappedSuperclass
+public class BaseEntity {
+
+ private Long id;
+ private Owner owner;
+ private Integer version;
+
+ @Id
+ @GeneratedValue
+ public Long getId() {
+ return id;
+ }
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "owner_id", nullable = false)
+ public Owner getOwner() {
+ return owner;
+ }
+
+ @Version
+ public Integer getVersion() {
+ return version;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public void setOwner(Owner owner) {
+ this.owner = owner;
+ }
+
+ public void setVersion(Integer version) {
+ this.version = version;
+ }
+}
Added:
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/Device.java
===================================================================
---
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/Device.java
(rev 0)
+++
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/Device.java 2010-01-27
14:55:49 UTC (rev 18647)
@@ -0,0 +1,37 @@
+package org.hibernate.test.annotations.onetoone.hhh4851;
+
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.OneToOne;
+
+@Entity
+@DiscriminatorValue(value = "T")
+public class Device extends Hardware {
+
+ private ManagedDevice managedDevice;
+ private String tag;
+
+ public Device() {
+ }
+
+ @OneToOne(fetch = FetchType.LAZY, mappedBy = "device")
+ public ManagedDevice getManagedDevice() {
+ return managedDevice;
+ }
+
+ @Column(unique = true, nullable = true)
+ public String getTag() {
+ return tag;
+ }
+
+ public void setManagedDevice(ManagedDevice logicalterminal) {
+ this.managedDevice = logicalterminal;
+ }
+
+ public void setTag(String tag) {
+ this.tag = tag;
+ }
+
+}
Added:
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/DeviceGroupConfig.java
===================================================================
---
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/DeviceGroupConfig.java
(rev 0)
+++
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/DeviceGroupConfig.java 2010-01-27
14:55:49 UTC (rev 18647)
@@ -0,0 +1,35 @@
+package org.hibernate.test.annotations.onetoone.hhh4851;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+/**
+ * A group of {@link LogicalTerminal logical terminals}. Used to group them for
Configuration purpose. That's why a
+ * LogicalTerminal can only have one TerminalGroup.
+ */
+@Entity
+@Table
+public class DeviceGroupConfig extends BaseEntity {
+
+ private String name = null;
+
+ public DeviceGroupConfig() {
+
+ }
+
+ /**
+ * Not unique, because we could use the same name in two different organizations.
+ *
+ * @return
+ */
+ @Column(nullable = false)
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
\ No newline at end of file
Added:
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/HHH4851Test.java
===================================================================
---
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/HHH4851Test.java
(rev 0)
+++
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/HHH4851Test.java 2010-01-27
14:55:49 UTC (rev 18647)
@@ -0,0 +1,50 @@
+package org.hibernate.test.annotations.onetoone.hhh4851;
+
+import org.hibernate.PropertyValueException;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.test.annotations.TestCase;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class HHH4851Test extends TestCase {
+
+ public void testHHH4851() throws Exception {
+ Session session = openSession();
+ Transaction trx = session.beginTransaction();
+ Owner org = new Owner();
+ org.setName( "root" );
+ session.saveOrUpdate( org );
+
+ ManagedDevice lTerminal = new ManagedDevice();
+ lTerminal.setName( "test" );
+ lTerminal.setOwner( org );
+ session.saveOrUpdate( lTerminal );
+
+ Device terminal = new Device();
+ terminal.setTag( "test" );
+ terminal.setOwner( org );
+ try {
+ session.saveOrUpdate( terminal );
+ }
+ catch ( PropertyValueException e ) {
+ fail( "not-null checking should not be raised: " + e.getMessage() );
+ }
+ trx.commit();
+ session.close();
+ }
+
+ @Override
+ protected Class<?>[] getMappings() {
+ return new Class<?>[] {
+ Hardware.class,
+ DeviceGroupConfig.class,
+ Hardware.class,
+ ManagedDevice.class,
+ Device.class,
+ Owner.class
+ };
+ }
+
+}
Added:
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/Hardware.java
===================================================================
---
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/Hardware.java
(rev 0)
+++
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/Hardware.java 2010-01-27
14:55:49 UTC (rev 18647)
@@ -0,0 +1,49 @@
+package org.hibernate.test.annotations.onetoone.hhh4851;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorType;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+
+import org.hibernate.annotations.Cascade;
+import org.hibernate.annotations.CascadeType;
+
+@Entity
+@Table
+@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
+@DiscriminatorColumn(discriminatorType = DiscriminatorType.STRING, name =
"DeviceType", length = 1)
+@DiscriminatorValue(value = "C")
+public class Hardware extends BaseEntity {
+
+ private Hardware parent = null;
+
+ protected Hardware() {
+
+ }
+
+ public Hardware(Hardware parent) {
+ this.parent = parent;
+
+ }
+
+ @OneToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "parent_id")
+ public Hardware getParent() {
+ return this.parent;
+ }
+
+ public void setParent(Hardware parent) {
+ this.parent = parent;
+ }
+
+}
Added:
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/ManagedDevice.java
===================================================================
---
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/ManagedDevice.java
(rev 0)
+++
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/ManagedDevice.java 2010-01-27
14:55:49 UTC (rev 18647)
@@ -0,0 +1,61 @@
+package org.hibernate.test.annotations.onetoone.hhh4851;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+
+/**
+ * this class represents a logical representation of a terminal it could be linked to a
terminal or not it contains the
+ * alias of the terminal and is virtualizable
+ */
+@Entity
+@Table(uniqueConstraints = { @UniqueConstraint(columnNames = { "name" }) })
+public class ManagedDevice extends BaseEntity {
+
+ private String name;
+ private Device device;
+ private DeviceGroupConfig deviceGroupConfig = null;
+
+ public ManagedDevice() {
+ }
+
+ public ManagedDevice(String alias) {
+ this.name = alias;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @OneToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "terminal_id")
+ public Device getDevice() {
+ return device;
+ }
+
+ @ManyToOne(optional = true, fetch = FetchType.LAZY)
+ @JoinTable(name = "ManDev_DevGroupConf",
+ joinColumns = { @JoinColumn(name = "MavDev_id", unique = true) },
+ inverseJoinColumns = { @JoinColumn(name = "DevGroupConf_id") })
+ public DeviceGroupConfig getDeviceGroupConfig() {
+ return deviceGroupConfig;
+ }
+
+ public void setName(String alias) {
+ this.name = alias;
+ }
+
+ public void setDevice(Device terminal) {
+ this.device = terminal;
+ }
+
+ public void setDeviceGroupConfig(DeviceGroupConfig terminalGroup) {
+ this.deviceGroupConfig = terminalGroup;
+ }
+
+}
Added:
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/Owner.java
===================================================================
---
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/Owner.java
(rev 0)
+++
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/hhh4851/Owner.java 2010-01-27
14:55:49 UTC (rev 18647)
@@ -0,0 +1,66 @@
+package org.hibernate.test.annotations.onetoone.hhh4851;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Version;
+
+@Entity
+@Table
+public class Owner {
+
+ private boolean deleted = false;
+ private Long id;
+
+ private String name;
+ private Integer version;
+
+ public Owner() {
+
+ }
+
+ public Owner(String name) {
+ this.name = name;
+ }
+
+ @Id
+ @GeneratedValue
+ public Long getId() {
+ return id;
+ }
+
+ @Column(nullable = false, unique = true)
+ public String getName() {
+ return name;
+ }
+
+ @Version
+ public Integer getVersion() {
+ return version;
+ }
+
+ public boolean isDeleted() {
+ return deleted;
+ }
+
+ public Owner setDeleted(boolean isDeleted) {
+ this.deleted = isDeleted;
+ return this;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Owner setName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ public void setVersion(Integer version) {
+ this.version = version;
+ }
+
+}
\ No newline at end of file
Show replies by date