Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHH-4417 - Add annotation support for UserCollectionType
- Loading branch information
Showing
29 changed files
with
604 additions
and
207 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
hibernate-core/src/main/java/org/hibernate/annotations/CollectionType.java
This file contains 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,60 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* Copyright (c) ${year}, Red Hat Inc. or third-party contributors as | ||
* indicated by the @author tags or express copyright attribution | ||
* statements applied by the authors. All third-party contributions are | ||
* distributed under license by Red Hat Inc. | ||
* | ||
* This copyrighted material is made available to anyone wishing to use, modify, | ||
* copy, or redistribute it subject to the terms and conditions of the GNU | ||
* Lesser General Public License, as published by the Free Software Foundation. | ||
* | ||
* This program 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 distribution; if not, write to: | ||
* Free Software Foundation, Inc. | ||
* 51 Franklin Street, Fifth Floor | ||
* Boston, MA 02110-1301 USA | ||
*/ | ||
package org.hibernate.annotations; | ||
|
||
import java.lang.annotation.*; | ||
|
||
import static java.lang.annotation.ElementType.FIELD; | ||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
/** | ||
* Names a custom collection type for a persistent collection. | ||
* | ||
* @see org.hibernate.type.CollectionType | ||
* @see org.hibernate.usertype.UserCollectionType | ||
* | ||
* @author Steve Ebersole | ||
*/ | ||
@java.lang.annotation.Target({FIELD, METHOD}) | ||
@Retention(RUNTIME) | ||
public @interface CollectionType { | ||
/** | ||
* Names the type (either {@link org.hibernate.type.CollectionType} or | ||
* {@link org.hibernate.usertype.UserCollectionType} implementation class. Could also name a | ||
* custom type defined via a {@link TypeDef @TypeDef} | ||
* | ||
* @return The implementation class to use. | ||
*/ | ||
String type(); | ||
|
||
/** | ||
* Specifies configuration information for the type. Note that if the named type is a | ||
* {@link org.hibernate.usertype.UserCollectionType}, it must also implement | ||
* {@link org.hibernate.usertype.ParameterizedType} in order to receive these values. | ||
* | ||
* @return The configuration parameters. | ||
*/ | ||
Parameter[] parameters() default {}; | ||
} |
This file contains 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
This file contains 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
75 changes: 75 additions & 0 deletions
75
hibernate-core/src/matrix/java/org/hibernate/test/collection/custom/basic/Email.java
This file contains 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,75 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* Copyright (c) ${year}, Red Hat Inc. or third-party contributors as | ||
* indicated by the @author tags or express copyright attribution | ||
* statements applied by the authors. All third-party contributions are | ||
* distributed under license by Red Hat Inc. | ||
* | ||
* This copyrighted material is made available to anyone wishing to use, modify, | ||
* copy, or redistribute it subject to the terms and conditions of the GNU | ||
* Lesser General Public License, as published by the Free Software Foundation. | ||
* | ||
* This program 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 distribution; if not, write to: | ||
* Free Software Foundation, Inc. | ||
* 51 Franklin Street, Fifth Floor | ||
* Boston, MA 02110-1301 USA | ||
*/ | ||
package org.hibernate.test.collection.custom.basic; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
|
||
/** | ||
* @author Gavin King | ||
* @author Steve Ebersole | ||
*/ | ||
@Entity | ||
public class Email { | ||
private Long id; | ||
private String address; | ||
|
||
Email() { | ||
} | ||
|
||
public Email(String address) { | ||
this.address = address; | ||
} | ||
|
||
@Id | ||
@GeneratedValue( strategy = GenerationType.AUTO ) | ||
public Long getId() { | ||
return id; | ||
} | ||
|
||
private void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getAddress() { | ||
return address; | ||
} | ||
|
||
public void setAddress(String type) { | ||
this.address = type; | ||
} | ||
|
||
public boolean equals(Object that) { | ||
if ( !(that instanceof Email) ) return false; | ||
Email p = (Email) that; | ||
return this.address.equals(p.address); | ||
} | ||
|
||
public int hashCode() { | ||
return address.hashCode(); | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
hibernate-core/src/matrix/java/org/hibernate/test/collection/custom/basic/IMyList.java
This file contains 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,29 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* Copyright (c) ${year}, Red Hat Inc. or third-party contributors as | ||
* indicated by the @author tags or express copyright attribution | ||
* statements applied by the authors. All third-party contributions are | ||
* distributed under license by Red Hat Inc. | ||
* | ||
* This copyrighted material is made available to anyone wishing to use, modify, | ||
* copy, or redistribute it subject to the terms and conditions of the GNU | ||
* Lesser General Public License, as published by the Free Software Foundation. | ||
* | ||
* This program 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 distribution; if not, write to: | ||
* Free Software Foundation, Inc. | ||
* 51 Franklin Street, Fifth Floor | ||
* Boston, MA 02110-1301 USA | ||
*/ | ||
package org.hibernate.test.collection.custom.basic; | ||
|
||
import java.util.List; | ||
|
||
public interface IMyList<X> extends List<X> { | ||
} |
35 changes: 35 additions & 0 deletions
35
hibernate-core/src/matrix/java/org/hibernate/test/collection/custom/basic/MyList.java
This file contains 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,35 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* Copyright (c) ${year}, Red Hat Inc. or third-party contributors as | ||
* indicated by the @author tags or express copyright attribution | ||
* statements applied by the authors. All third-party contributions are | ||
* distributed under license by Red Hat Inc. | ||
* | ||
* This copyrighted material is made available to anyone wishing to use, modify, | ||
* copy, or redistribute it subject to the terms and conditions of the GNU | ||
* Lesser General Public License, as published by the Free Software Foundation. | ||
* | ||
* This program 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 distribution; if not, write to: | ||
* Free Software Foundation, Inc. | ||
* 51 Franklin Street, Fifth Floor | ||
* Boston, MA 02110-1301 USA | ||
*/ | ||
package org.hibernate.test.collection.custom.basic; | ||
|
||
import java.util.ArrayList; | ||
|
||
/** | ||
* A custom collection class. We extend a java.util.Collection class, but that is not required. | ||
* It could be totally non-java-collection type, but then we would need to implement all the PersistentCollection methods. | ||
* | ||
* @author max | ||
*/ | ||
public class MyList<X> extends ArrayList<X> implements IMyList<X> { | ||
} |
4 changes: 2 additions & 2 deletions
4
...test/usercollection/basic/MyListType.java → ...t/collection/custom/basic/MyListType.java
This file contains 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
2 changes: 1 addition & 1 deletion
2
...sercollection/basic/PersistentMyList.java → ...ection/custom/basic/PersistentMyList.java
This file contains 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
Oops, something went wrong.