From 87c75ad0365a4df3732548099a4378ff4c92ae7a Mon Sep 17 00:00:00 2001 From: Juraci Krohling Date: Thu, 4 Jun 2009 18:27:00 +0000 Subject: [PATCH] ANN-840 - Added explicit not-null in foreign keys, as workaround for JBPAPP-1071 git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@16698 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../hibernate/test/annotations/collectionelement/Boy.java | 5 ++++- .../test/annotations/collectionelement/LocalizedString.java | 2 +- .../hibernate/test/annotations/collectionelement/Matrix.java | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Boy.java b/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Boy.java index 4a54bb4611..52c4b47939 100644 --- a/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Boy.java +++ b/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Boy.java @@ -5,9 +5,11 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; + import javax.persistence.AttributeOverride; import javax.persistence.AttributeOverrides; import javax.persistence.Column; +import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; @@ -16,10 +18,10 @@ import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; -import javax.persistence.ElementCollection; import org.hibernate.annotations.CollectionOfElements; import org.hibernate.annotations.IndexColumn; +import org.hibernate.annotations.MapKey; /** * @author Emmanuel Bernard @@ -79,6 +81,7 @@ public class Boy { @ElementCollection @JoinTable(name = "ScorePerNickName", joinColumns = @JoinColumn(name = "BoyId")) @Column(name = "score", nullable = false) + @MapKey(columns=@Column( name = "mapkey", nullable=false )) public Map getScorePerNickName() { return scorePerNickName; } diff --git a/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/LocalizedString.java b/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/LocalizedString.java index 5749475d98..53341bf20a 100644 --- a/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/LocalizedString.java +++ b/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/LocalizedString.java @@ -33,7 +33,7 @@ public class LocalizedString implements Serializable { new HashMap( 1 ); @ElementCollection - @MapKey( columns = @Column( name = "language_code" ) ) + @MapKey( columns = @Column( name = "language_code", nullable=false ) ) @Fetch( FetchMode.JOIN ) @Filter( name = "selectedLocale", condition = " language_code = :param " ) diff --git a/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Matrix.java b/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Matrix.java index 3cdf325fde..820ac1f216 100644 --- a/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Matrix.java +++ b/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Matrix.java @@ -4,6 +4,8 @@ package org.hibernate.test.annotations.collectionelement; import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; + +import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -23,7 +25,7 @@ public class Matrix { @GeneratedValue private Integer id; - @MapKey(type = @Type(type="integer") ) + @MapKey(type = @Type(type="integer"), columns=@Column( name = "mapkey", nullable=false ) ) @ElementCollection @Sort(type = SortType.NATURAL) @Type(type = "float")