Project

General

Profile

Download (11.9 KB) Statistics
| Branch: | Tag: | Revision:
1 9479da48 Andreas Müller
/* Package Annotations*/
2
3 ee91bcd9 ben.clark
@javax.xml.bind.annotation.XmlSchema(namespace = "http://etaxonomy.eu/cdm/model/common/1.0", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
4 a784f00f Katja Luther
@com.sun.xml.bind.XmlAccessorFactory(eu.etaxonomy.cdm.jaxb.CdmAccessorFactoryImpl.class)
5 8b4b44e9 n.hoffmann
@org.hibernate.annotations.GenericGenerators(
6
	{
7 12ec48f6 n.hoffmann
		/* @see {@link eu.etaxonomy.cdm.persistence.hibernate.TableGenerator} */
8
		@GenericGenerator(
9 5d73efbd Andreas Kohlbecker
				name="custom-enhanced-table",
10 12ec48f6 n.hoffmann
				strategy = "eu.etaxonomy.cdm.persistence.hibernate.TableGenerator",
11
				parameters = {
12
				    @Parameter(name="optimizer", value = "pooled"),
13
				    /* initial_value = increment_size as proposed to fix an issue with pooled optimizer
14
				     * http://opensource.atlassian.com/projects/hibernate/browse/HHH-3608?focusedCommentId=37112&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_37112
15
				     */
16
				    @Parameter(name="initial_value", value= "10"),
17
				    @Parameter(name="increment_size", value = "10"),
18
				    /* we want to have a sequence per table */
19
				    @Parameter(name="prefer_entity_table_as_segment_value", value="true")
20
				}
21
		),
22 a8826ea6 n.hoffmann
		/* Steve Ebersole of Hibernate highly recommends the use of the two new generators
23
		 * http://relation.to/2082.lace
24
		 * Also see: http://docs.jboss.org/hibernate/core/3.3/reference/en/html/mapping.html#mapping-declaration-id-enhanced
25
		 */
26
		/* new table generator
27
		 * always stores sequences in a table. May be configured to return a sequence on a per table basis
28 5d73efbd Andreas Kohlbecker
		 * RECOMMENDED WHEN RUNNING A CDM DATASOURCE IN A MULTI CLIENT ENVIRONMENT
29 a8826ea6 n.hoffmann
		 */
30
		@GenericGenerator(
31 5d73efbd Andreas Kohlbecker
				name="enhanced-table",
32 a8826ea6 n.hoffmann
				strategy = "org.hibernate.id.enhanced.TableGenerator",
33
				parameters = {
34
				    @Parameter(name="optimizer", value = "pooled"),
35
				    /* initial_value = increment_size as proposed to fix an issue with pooled optimizer
36
				     * http://opensource.atlassian.com/projects/hibernate/browse/HHH-3608?focusedCommentId=37112&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_37112
37
				     */
38
				    @Parameter(name="initial_value", value= "10"),
39
				    @Parameter(name="increment_size", value = "10"),
40
				    /* we want to have a sequence per table */
41
				    @Parameter(name="prefer_entity_table_as_segment_value", value="true")
42
				}
43
		),
44
		/* new sequence generator
45
		 * Using sequence when the dialect supports it, otherwise it will emulate a sequence using a table in the db
46
		 * This method will result in database wide unique id's */
47
		@GenericGenerator(
48 5d73efbd Andreas Kohlbecker
				name="enhanced-sequence",
49 a8826ea6 n.hoffmann
				strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
50
				parameters = {
51
			        @Parameter(name="optimizer", value = "pooled"),
52
			        /* initial_value = increment_size as proposed to fix an issue with pooled optimizer
53
				     * http://opensource.atlassian.com/projects/hibernate/browse/HHH-3608?focusedCommentId=37112&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_37112
54
				     */
55
				    @Parameter(name="initial_value", value= "10"),
56
				    @Parameter(name="increment_size", value = "10")
57
			    }
58
		),
59
		/* A couple of old style generators */
60 5d73efbd Andreas Kohlbecker
		/* generates identifiers of type long, short or int that are unique only when no other process
61
		 * is inserting data into the same table.
62 a8826ea6 n.hoffmann
		 * DO NOT USE IN A CLUSTER OR MULTIPLE CLIENT ENVIRONMENT */
63 5d73efbd Andreas Kohlbecker
		@GenericGenerator(
64
				name="system-increment",
65 8b4b44e9 n.hoffmann
				strategy = "increment"
66
		),
67 5d73efbd Andreas Kohlbecker
		/* supports identity columns in DB2, MySQL, MS SQL Server, Sybase and HypersonicSQL.
68 8b4b44e9 n.hoffmann
		 * The returned identifier is of type long, short or int. */
69
		@GenericGenerator(
70 5d73efbd Andreas Kohlbecker
				name="system-identity",
71 8b4b44e9 n.hoffmann
				strategy = "identity"
72 5d73efbd Andreas Kohlbecker
73 8b4b44e9 n.hoffmann
		),
74 5d73efbd Andreas Kohlbecker
		/* uses a hi/lo algorithm to efficiently generate identifiers of type long, short or int,
75
		 * given a table and column (by default hibernate_unique_key and next_hi respectively) as
76
		 * a source of hi values. The hi/lo algorithm generates identifiers that are unique only
77 8b4b44e9 n.hoffmann
		 * for a particular database. */
78
		@GenericGenerator(
79 5d73efbd Andreas Kohlbecker
				name="system-hilo",
80 8b4b44e9 n.hoffmann
				strategy = "hilo"
81
		),
82 5d73efbd Andreas Kohlbecker
		/* uses a sequence in DB2, PostgreSQL, Oracle, SAP DB, McKoi or a generator in Interbase.
83 8b4b44e9 n.hoffmann
		 * The returned identifier is of type long, short or int */
84
		@GenericGenerator(
85 5d73efbd Andreas Kohlbecker
				name="system-sequence",
86 8b4b44e9 n.hoffmann
				strategy = "sequence"
87
		),
88
		/* selects identity, sequence or hilo depending upon the capabilities of the underlying database. */
89
		@GenericGenerator(
90 5d73efbd Andreas Kohlbecker
				name="system-native",
91 8b4b44e9 n.hoffmann
				strategy = "native"
92
		)
93
	}
94 744c877b n.hoffmann
)
95
96
97
98 5d73efbd Andreas Kohlbecker
@org.hibernate.annotations.TypeDefs( {
99 a13c5f66 Andreas Müller
	//TODO needed ??
100 5d73efbd Andreas Kohlbecker
	@org.hibernate.annotations.TypeDef(name="persistentDuration", typeClass=org.jadira.usertype.dateandtime.joda.PersistentDurationAsString.class),
101 a13c5f66 Andreas Müller
	@org.hibernate.annotations.TypeDef(name="dateTimeUserType", typeClass=org.jadira.usertype.dateandtime.joda.PersistentDateTime.class),
102 1d36aa54 Andreas Müller
	@org.hibernate.annotations.TypeDef(name="partialUserType", typeClass=eu.etaxonomy.cdm.hibernate.PartialUserType.class),
103
	@org.hibernate.annotations.TypeDef(name="uuidUserType", typeClass=eu.etaxonomy.cdm.hibernate.UUIDUserType.class),
104 5f9ffdeb Andreas Müller
	@org.hibernate.annotations.TypeDef(name="uriUserType", typeClass=eu.etaxonomy.cdm.hibernate.URIUserType.class),
105 87e91505 Andreas Müller
	@org.hibernate.annotations.TypeDef(name="enumUserType", typeClass=eu.etaxonomy.cdm.hibernate.EnumUserType.class),	
106
	@org.hibernate.annotations.TypeDef(name="doiUserType", typeClass=eu.etaxonomy.cdm.hibernate.DOIUserType.class)	
107 cfbd62fa Andreas Müller
})
108 1a35ee20 ben.clark
@org.hibernate.annotations.AnyMetaDef(name = "CdmBase" ,
109 5d73efbd Andreas Kohlbecker
		                              metaType="string",
110 ec73a350 ben.clark
		                              idType="integer",
111
		                              metaValues={
112 ee91bcd9 ben.clark
		@MetaValue(value = "eu.etaxonomy.cdm.model.agent.Institution", targetEntity = Institution.class),
113
		@MetaValue(value = "eu.etaxonomy.cdm.model.agent.Person", targetEntity = Person.class),
114
		@MetaValue(value = "eu.etaxonomy.cdm.model.agent.Team", targetEntity = Team.class),
115
		@MetaValue(value = "eu.etaxonomy.cdm.model.common.Annotation", targetEntity = Annotation.class),
116 17f0cc4b h.fradin
		@MetaValue(value = "eu.etaxonomy.cdm.model.description.MediaKey", targetEntity = MediaKey.class),
117 ee91bcd9 ben.clark
		@MetaValue(value = "eu.etaxonomy.cdm.model.description.TaxonDescription", targetEntity = TaxonDescription.class),
118
		@MetaValue(value = "eu.etaxonomy.cdm.model.description.SpecimenDescription", targetEntity = SpecimenDescription.class),
119 5d49833e ben.clark
		@MetaValue(value = "eu.etaxonomy.cdm.model.description.TaxonNameDescription", targetEntity = TaxonNameDescription.class),
120 51db8d4a ben.clark
		@MetaValue(value = "eu.etaxonomy.cdm.model.description.CategoricalData", targetEntity = CategoricalData.class),
121
		@MetaValue(value = "eu.etaxonomy.cdm.model.description.CommonTaxonName", targetEntity = CommonTaxonName.class),
122
		@MetaValue(value = "eu.etaxonomy.cdm.model.description.Distribution", targetEntity = Distribution.class),
123
		@MetaValue(value = "eu.etaxonomy.cdm.model.description.IndividualsAssociation", targetEntity = IndividualsAssociation.class),
124
		@MetaValue(value = "eu.etaxonomy.cdm.model.description.QuantitativeData", targetEntity = QuantitativeData.class),
125
		@MetaValue(value = "eu.etaxonomy.cdm.model.description.TaxonInteraction", targetEntity = TaxonInteraction.class),
126 5d49833e ben.clark
		@MetaValue(value = "eu.etaxonomy.cdm.model.media.Media", targetEntity = Media.class),
127
		@MetaValue(value = "eu.etaxonomy.cdm.model.molecular.Sequence", targetEntity = Sequence.class),
128
		@MetaValue(value = "eu.etaxonomy.cdm.model.name.BacterialName", targetEntity = BacterialName.class),
129
		@MetaValue(value = "eu.etaxonomy.cdm.model.name.BotanicalName", targetEntity = BotanicalName.class),
130
		@MetaValue(value = "eu.etaxonomy.cdm.model.name.CultivarPlantName", targetEntity = CultivarPlantName.class),
131
		@MetaValue(value = "eu.etaxonomy.cdm.model.name.ViralName", targetEntity = ViralName.class),
132
		@MetaValue(value = "eu.etaxonomy.cdm.model.name.ZoologicalName", targetEntity = ZoologicalName.class),
133
		@MetaValue(value = "eu.etaxonomy.cdm.model.occurrence.Collection", targetEntity = Collection.class),
134 c150ee7f Andreas Müller
		@MetaValue(value = "eu.etaxonomy.cdm.model.occurrence.FieldUnit", targetEntity = FieldUnit.class),
135 483579cd Andreas Müller
		@MetaValue(value = "eu.etaxonomy.cdm.model.occurrence.DerivedUnit", targetEntity = DerivedUnit.class),
136 1d36aa54 Andreas Müller
		@MetaValue(value = "eu.etaxonomy.cdm.model.reference.Reference", targetEntity = Reference.class),
137
		@MetaValue(value = "eu.etaxonomy.cdm.model.reference.Journal", targetEntity = Reference.class),
138
		@MetaValue(value = "eu.etaxonomy.cdm.model.reference.Article", targetEntity = Reference.class),
139
		@MetaValue(value = "eu.etaxonomy.cdm.model.reference.Book", targetEntity = Reference.class),
140
		@MetaValue(value = "eu.etaxonomy.cdm.model.reference.Generic", targetEntity = Reference.class),
141
		@MetaValue(value = "eu.etaxonomy.cdm.model.reference.Database", targetEntity = Reference.class),
142
		@MetaValue(value = "eu.etaxonomy.cdm.model.reference.BookSection", targetEntity = Reference.class),
143
		@MetaValue(value = "eu.etaxonomy.cdm.model.reference.Reference", targetEntity = Reference.class),
144
		@MetaValue(value = "eu.etaxonomy.cdm.model.reference.PrintSeries", targetEntity = Reference.class),
145
		@MetaValue(value = "eu.etaxonomy.cdm.model.reference.Proceedings", targetEntity = Reference.class),
146
		@MetaValue(value = "eu.etaxonomy.cdm.model.reference.Thesis", targetEntity = Reference.class),
147
		@MetaValue(value = "eu.etaxonomy.cdm.model.reference.WebPage", targetEntity = Reference.class),
148 ee91bcd9 ben.clark
		@MetaValue(value = "eu.etaxonomy.cdm.model.taxon.Synonym", targetEntity = Synonym.class),
149 b5513990 Katja Luther
		@MetaValue(value = "eu.etaxonomy.cdm.model.taxon.Taxon", targetEntity = Taxon.class),
150 1d36aa54 Andreas Müller
		@MetaValue(value = "eu.etaxonomy.cdm.model.taxon.Classification", targetEntity = Classification.class),
151 5453a1c9 Katja Luther
		@MetaValue(value = "eu.etaxonomy.cdm.model.description.TextData", targetEntity = TextData.class),
152 4eef75ef Katja Luther
		@MetaValue(value = "eu.etaxonomy.cdm.model.agent.TeamOrPersonBase", targetEntity = TeamOrPersonBase.class),
153 3a45cdbe Cherian Mathew
		@MetaValue(value = "eu.etaxonomy.cdm.model.common.User", targetEntity = User.class),
154 fe8256b3 Cherian Mathew
		@MetaValue(value = "eu.etaxonomy.cdm.model.description.PolytomousKey", targetEntity = PolytomousKey.class),
155
		@MetaValue(value = "eu.etaxonomy.cdm.model.name.NomenclaturalStatus", targetEntity = NomenclaturalStatus.class)
156 b5513990 Katja Luther
})
157 9479da48 Andreas Müller
package eu.etaxonomy.cdm.model.common;
158
159 ec73a350 ben.clark
import org.hibernate.annotations.GenericGenerator;
160 5d49833e ben.clark
import org.hibernate.annotations.MetaValue;
161 8b4b44e9 n.hoffmann
import org.hibernate.annotations.Parameter;
162 5d49833e ben.clark
163 ec73a350 ben.clark
import eu.etaxonomy.cdm.model.agent.Institution;
164
import eu.etaxonomy.cdm.model.agent.Person;
165
import eu.etaxonomy.cdm.model.agent.Team;
166 5453a1c9 Katja Luther
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
167 51db8d4a ben.clark
import eu.etaxonomy.cdm.model.description.CategoricalData;
168
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
169
import eu.etaxonomy.cdm.model.description.Distribution;
170
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
171 17f0cc4b h.fradin
import eu.etaxonomy.cdm.model.description.MediaKey;
172 5d73efbd Andreas Kohlbecker
import eu.etaxonomy.cdm.model.description.PolytomousKey;
173 51db8d4a ben.clark
import eu.etaxonomy.cdm.model.description.QuantitativeData;
174 ec73a350 ben.clark
import eu.etaxonomy.cdm.model.description.SpecimenDescription;
175
import eu.etaxonomy.cdm.model.description.TaxonDescription;
176 51db8d4a ben.clark
import eu.etaxonomy.cdm.model.description.TaxonInteraction;
177 5d49833e ben.clark
import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
178 b5513990 Katja Luther
import eu.etaxonomy.cdm.model.description.TextData;
179 5d49833e ben.clark
import eu.etaxonomy.cdm.model.media.Media;
180
import eu.etaxonomy.cdm.model.molecular.Sequence;
181
import eu.etaxonomy.cdm.model.name.BacterialName;
182
import eu.etaxonomy.cdm.model.name.BotanicalName;
183
import eu.etaxonomy.cdm.model.name.CultivarPlantName;
184 fe8256b3 Cherian Mathew
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
185 5d49833e ben.clark
import eu.etaxonomy.cdm.model.name.ViralName;
186
import eu.etaxonomy.cdm.model.name.ZoologicalName;
187
import eu.etaxonomy.cdm.model.occurrence.Collection;
188 c150ee7f Andreas Müller
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
189 483579cd Andreas Müller
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
190 1d36aa54 Andreas Müller
import eu.etaxonomy.cdm.model.reference.Reference;
191 5d73efbd Andreas Kohlbecker
import eu.etaxonomy.cdm.model.taxon.Classification;
192 ec73a350 ben.clark
import eu.etaxonomy.cdm.model.taxon.Synonym;
193
import eu.etaxonomy.cdm.model.taxon.Taxon;
194 5d73efbd Andreas Kohlbecker