| 1 | /* Package Annotations*/ |
|---|
| 2 | |
|---|
| 3 | @javax.xml.bind.annotation.XmlSchema(namespace = "http://etaxonomy.eu/cdm/model/common/1.0", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) |
|---|
| 4 | @com.sun.xml.bind.XmlAccessorFactory(eu.etaxonomy.cdm.jaxb.CdmAccessorFactoryImpl.class) |
|---|
| 5 | @org.hibernate.annotations.GenericGenerators( |
|---|
| 6 | { |
|---|
| 7 | /* @see {@link eu.etaxonomy.cdm.persistence.hibernate.TableGenerator} */ |
|---|
| 8 | @GenericGenerator( |
|---|
| 9 | name="custom-enhanced-table", |
|---|
| 10 | 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 | /* 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 | * RECOMMENDED WHEN RUNNING A CDM DATASOURCE IN A MULTI CLIENT ENVIRONMENT |
|---|
| 29 | */ |
|---|
| 30 | @GenericGenerator( |
|---|
| 31 | name="enhanced-table", |
|---|
| 32 | 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 | name="enhanced-sequence", |
|---|
| 49 | 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 | /* 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 | * DO NOT USE IN A CLUSTER OR MULTIPLE CLIENT ENVIRONMENT */ |
|---|
| 63 | @GenericGenerator( |
|---|
| 64 | name="system-increment", |
|---|
| 65 | strategy = "increment" |
|---|
| 66 | ), |
|---|
| 67 | /* supports identity columns in DB2, MySQL, MS SQL Server, Sybase and HypersonicSQL. |
|---|
| 68 | * The returned identifier is of type long, short or int. */ |
|---|
| 69 | @GenericGenerator( |
|---|
| 70 | name="system-identity", |
|---|
| 71 | strategy = "identity" |
|---|
| 72 | |
|---|
| 73 | ), |
|---|
| 74 | /* 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 | * for a particular database. */ |
|---|
| 78 | @GenericGenerator( |
|---|
| 79 | name="system-hilo", |
|---|
| 80 | strategy = "hilo" |
|---|
| 81 | ), |
|---|
| 82 | /* uses a sequence in DB2, PostgreSQL, Oracle, SAP DB, McKoi or a generator in Interbase. |
|---|
| 83 | * The returned identifier is of type long, short or int */ |
|---|
| 84 | @GenericGenerator( |
|---|
| 85 | name="system-sequence", |
|---|
| 86 | strategy = "sequence" |
|---|
| 87 | ), |
|---|
| 88 | /* selects identity, sequence or hilo depending upon the capabilities of the underlying database. */ |
|---|
| 89 | @GenericGenerator( |
|---|
| 90 | name="system-native", |
|---|
| 91 | strategy = "native" |
|---|
| 92 | ) |
|---|
| 93 | } |
|---|
| 94 | ) |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | |
|---|
| 98 | @org.hibernate.annotations.TypeDefs( { |
|---|
| 99 | @org.hibernate.annotations.TypeDef(name="persistentDuration", typeClass=org.joda.time.contrib.hibernate.PersistentDuration.class), |
|---|
| 100 | @org.hibernate.annotations.TypeDef(name="dateTimeUserType", typeClass=org.joda.time.contrib.hibernate.PersistentDateTime.class), |
|---|
| 101 | @org.hibernate.annotations.TypeDef(name="partialUserType", typeClass=eu.etaxonomy.cdm.hibernate.PartialUserType.class), |
|---|
| 102 | @org.hibernate.annotations.TypeDef(name="uuidUserType", typeClass=eu.etaxonomy.cdm.hibernate.UUIDUserType.class), |
|---|
| 103 | @org.hibernate.annotations.TypeDef(name="uriUserType", typeClass=eu.etaxonomy.cdm.hibernate.URIUserType.class) |
|---|
| 104 | }) |
|---|
| 105 | @org.hibernate.annotations.AnyMetaDef(name = "CdmBase" , |
|---|
| 106 | metaType="string", |
|---|
| 107 | idType="integer", |
|---|
| 108 | metaValues={ |
|---|
| 109 | @MetaValue(value = "eu.etaxonomy.cdm.model.agent.Institution", targetEntity = Institution.class), |
|---|
| 110 | @MetaValue(value = "eu.etaxonomy.cdm.model.agent.Person", targetEntity = Person.class), |
|---|
| 111 | @MetaValue(value = "eu.etaxonomy.cdm.model.agent.Team", targetEntity = Team.class), |
|---|
| 112 | @MetaValue(value = "eu.etaxonomy.cdm.model.common.Annotation", targetEntity = Annotation.class), |
|---|
| 113 | @MetaValue(value = "eu.etaxonomy.cdm.model.description.MediaKey", targetEntity = MediaKey.class), |
|---|
| 114 | @MetaValue(value = "eu.etaxonomy.cdm.model.description.TaxonDescription", targetEntity = TaxonDescription.class), |
|---|
| 115 | @MetaValue(value = "eu.etaxonomy.cdm.model.description.SpecimenDescription", targetEntity = SpecimenDescription.class), |
|---|
| 116 | @MetaValue(value = "eu.etaxonomy.cdm.model.description.TaxonNameDescription", targetEntity = TaxonNameDescription.class), |
|---|
| 117 | @MetaValue(value = "eu.etaxonomy.cdm.model.description.CategoricalData", targetEntity = CategoricalData.class), |
|---|
| 118 | @MetaValue(value = "eu.etaxonomy.cdm.model.description.CommonTaxonName", targetEntity = CommonTaxonName.class), |
|---|
| 119 | @MetaValue(value = "eu.etaxonomy.cdm.model.description.Distribution", targetEntity = Distribution.class), |
|---|
| 120 | @MetaValue(value = "eu.etaxonomy.cdm.model.description.IndividualsAssociation", targetEntity = IndividualsAssociation.class), |
|---|
| 121 | @MetaValue(value = "eu.etaxonomy.cdm.model.description.QuantitativeData", targetEntity = QuantitativeData.class), |
|---|
| 122 | @MetaValue(value = "eu.etaxonomy.cdm.model.description.TaxonInteraction", targetEntity = TaxonInteraction.class), |
|---|
| 123 | @MetaValue(value = "eu.etaxonomy.cdm.model.media.Media", targetEntity = Media.class), |
|---|
| 124 | @MetaValue(value = "eu.etaxonomy.cdm.model.molecular.Sequence", targetEntity = Sequence.class), |
|---|
| 125 | @MetaValue(value = "eu.etaxonomy.cdm.model.name.BacterialName", targetEntity = BacterialName.class), |
|---|
| 126 | @MetaValue(value = "eu.etaxonomy.cdm.model.name.BotanicalName", targetEntity = BotanicalName.class), |
|---|
| 127 | @MetaValue(value = "eu.etaxonomy.cdm.model.name.CultivarPlantName", targetEntity = CultivarPlantName.class), |
|---|
| 128 | @MetaValue(value = "eu.etaxonomy.cdm.model.name.ViralName", targetEntity = ViralName.class), |
|---|
| 129 | @MetaValue(value = "eu.etaxonomy.cdm.model.name.ZoologicalName", targetEntity = ZoologicalName.class), |
|---|
| 130 | @MetaValue(value = "eu.etaxonomy.cdm.model.occurrence.Collection", targetEntity = Collection.class), |
|---|
| 131 | @MetaValue(value = "eu.etaxonomy.cdm.model.occurrence.DerivedUnit", targetEntity = DerivedUnit.class), |
|---|
| 132 | @MetaValue(value = "eu.etaxonomy.cdm.model.occurrence.FieldObservation", targetEntity = FieldObservation.class), |
|---|
| 133 | @MetaValue(value = "eu.etaxonomy.cdm.model.occurrence.Fossil", targetEntity = Fossil.class), |
|---|
| 134 | @MetaValue(value = "eu.etaxonomy.cdm.model.occurrence.LivingBeing", targetEntity = LivingBeing.class), |
|---|
| 135 | @MetaValue(value = "eu.etaxonomy.cdm.model.occurrence.Observation", targetEntity = Observation.class), |
|---|
| 136 | @MetaValue(value = "eu.etaxonomy.cdm.model.occurrence.Specimen", targetEntity = Specimen.class), |
|---|
| 137 | @MetaValue(value = "eu.etaxonomy.cdm.model.reference.Reference", targetEntity = Reference.class), |
|---|
| 138 | @MetaValue(value = "eu.etaxonomy.cdm.model.reference.Journal", targetEntity = Reference.class), |
|---|
| 139 | @MetaValue(value = "eu.etaxonomy.cdm.model.reference.Article", targetEntity = Reference.class), |
|---|
| 140 | @MetaValue(value = "eu.etaxonomy.cdm.model.reference.Book", targetEntity = Reference.class), |
|---|
| 141 | @MetaValue(value = "eu.etaxonomy.cdm.model.reference.Generic", targetEntity = Reference.class), |
|---|
| 142 | @MetaValue(value = "eu.etaxonomy.cdm.model.reference.Database", targetEntity = Reference.class), |
|---|
| 143 | @MetaValue(value = "eu.etaxonomy.cdm.model.reference.BookSection", targetEntity = Reference.class), |
|---|
| 144 | @MetaValue(value = "eu.etaxonomy.cdm.model.reference.Reference", targetEntity = Reference.class), |
|---|
| 145 | @MetaValue(value = "eu.etaxonomy.cdm.model.reference.PrintSeries", targetEntity = Reference.class), |
|---|
| 146 | @MetaValue(value = "eu.etaxonomy.cdm.model.reference.Proceedings", targetEntity = Reference.class), |
|---|
| 147 | @MetaValue(value = "eu.etaxonomy.cdm.model.reference.Thesis", targetEntity = Reference.class), |
|---|
| 148 | @MetaValue(value = "eu.etaxonomy.cdm.model.reference.WebPage", targetEntity = Reference.class), |
|---|
| 149 | @MetaValue(value = "eu.etaxonomy.cdm.model.taxon.Synonym", targetEntity = Synonym.class), |
|---|
| 150 | @MetaValue(value = "eu.etaxonomy.cdm.model.taxon.Taxon", targetEntity = Taxon.class), |
|---|
| 151 | @MetaValue(value = "eu.etaxonomy.cdm.model.taxon.Classification", targetEntity = Classification.class), |
|---|
| 152 | @MetaValue(value = "eu.etaxonomy.cdm.model.description.TextData", targetEntity = TextData.class), |
|---|
| 153 | @MetaValue(value = "eu.etaxonomy.cdm.model.agent.TeamOrPersonBase", targetEntity = TeamOrPersonBase.class), |
|---|
| 154 | @MetaValue(value = "eu.etaxonomy.cdm.model.common.User", targetEntity = User.class) |
|---|
| 155 | }) |
|---|
| 156 | package eu.etaxonomy.cdm.model.common; |
|---|
| 157 | |
|---|
| 158 | import org.hibernate.annotations.GenericGenerator; |
|---|
| 159 | import org.hibernate.annotations.MetaValue; |
|---|
| 160 | import org.hibernate.annotations.Parameter; |
|---|
| 161 | |
|---|
| 162 | import eu.etaxonomy.cdm.model.agent.Institution; |
|---|
| 163 | import eu.etaxonomy.cdm.model.agent.Person; |
|---|
| 164 | import eu.etaxonomy.cdm.model.agent.Team; |
|---|
| 165 | import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
|---|
| 166 | import eu.etaxonomy.cdm.model.description.CategoricalData; |
|---|
| 167 | import eu.etaxonomy.cdm.model.description.CommonTaxonName; |
|---|
| 168 | import eu.etaxonomy.cdm.model.description.Distribution; |
|---|
| 169 | import eu.etaxonomy.cdm.model.description.IndividualsAssociation; |
|---|
| 170 | import eu.etaxonomy.cdm.model.description.MediaKey; |
|---|
| 171 | import eu.etaxonomy.cdm.model.description.QuantitativeData; |
|---|
| 172 | import eu.etaxonomy.cdm.model.description.SpecimenDescription; |
|---|
| 173 | import eu.etaxonomy.cdm.model.description.TaxonDescription; |
|---|
| 174 | import eu.etaxonomy.cdm.model.description.TaxonInteraction; |
|---|
| 175 | import eu.etaxonomy.cdm.model.description.TaxonNameDescription; |
|---|
| 176 | import eu.etaxonomy.cdm.model.description.TextData; |
|---|
| 177 | import eu.etaxonomy.cdm.model.media.Media; |
|---|
| 178 | import eu.etaxonomy.cdm.model.molecular.Sequence; |
|---|
| 179 | import eu.etaxonomy.cdm.model.name.BacterialName; |
|---|
| 180 | import eu.etaxonomy.cdm.model.name.BotanicalName; |
|---|
| 181 | import eu.etaxonomy.cdm.model.name.CultivarPlantName; |
|---|
| 182 | import eu.etaxonomy.cdm.model.name.ViralName; |
|---|
| 183 | import eu.etaxonomy.cdm.model.name.ZoologicalName; |
|---|
| 184 | import eu.etaxonomy.cdm.model.occurrence.Collection; |
|---|
| 185 | import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; |
|---|
| 186 | import eu.etaxonomy.cdm.model.occurrence.FieldObservation; |
|---|
| 187 | import eu.etaxonomy.cdm.model.occurrence.Fossil; |
|---|
| 188 | import eu.etaxonomy.cdm.model.occurrence.LivingBeing; |
|---|
| 189 | import eu.etaxonomy.cdm.model.occurrence.Observation; |
|---|
| 190 | import eu.etaxonomy.cdm.model.occurrence.Specimen; |
|---|
| 191 | import eu.etaxonomy.cdm.model.reference.Reference; |
|---|
| 192 | import eu.etaxonomy.cdm.model.taxon.Synonym; |
|---|
| 193 | import eu.etaxonomy.cdm.model.taxon.Taxon; |
|---|
| 194 | import eu.etaxonomy.cdm.model.taxon.Classification; |
|---|
| 195 | |
|---|