[Hibernate-JIRA] Created: (ANN-606) Annotation Validation: @Immutable annotation does not throw error or warning on usage on subclass
by Paul Singleton Kossler (JIRA)
Annotation Validation: @Immutable annotation does not throw error or warning on usage on subclass
--------------------------------------------------------------------------------------------------
Key: ANN-606
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-606
Project: Hibernate Annotations
Issue Type: Bug
Components: binder, documentation
Affects Versions: 3.3.0.ga
Environment: Hibernate3, Annotations.3.3.0
Reporter: Paul Singleton Kossler
The @Immutable annotation does not throw a configuration error when used on a subclass. The action required depends upon the decision in a bug/patch request for adding mutable=false to subclasses. In the current rule set the Mapping Schema for pre annotations is leveraged to define the legallity of declaring a mapped object Immutable. Base/Root classes allowed, child classes of Mutable=true not allowed, in either case the mutability of an object is directly dependent upon the mutability of the root mapped object in the object hierarchy.
The following documentation sources do not mention the issue in relation to the @Immutable annotation:
* online/down-loadable Hibernate-Annotations
* Java Persistence with Hibernate (ISBN: 1-932394-88-5)
If the rules outlined above are accurate or not: A validation error or warning should be thrown from Configuration during the loading of an incorrectly mapped class. The current method is to check the Annotations at bind time, and only at the "correct" location. This meta-rule validation should occur during the binding of a mapping to the Configuration, quickly indicating an error. Using the "older" xml based mapping this occurs when the schema (xsd) validates the mapping file (xml).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
18 years
[Hibernate-JIRA] Created: (ANN-551) @SQLInsert. Columns in sql comes in different order depending on the application server used
by Søren Pedersen (JIRA)
@SQLInsert. Columns in sql comes in different order depending on the application server used
--------------------------------------------------------------------------------------------
Key: ANN-551
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-551
Project: Hibernate Annotations
Type: Bug
Components: binder
Versions: 3.2.1
Environment: Hibernate-core 3.2.2, hibernate-annotations 3.2.1. WebLogic 9.2 and JBoss 4.0.5. Oracle 10.
Reporter: Søren Pedersen
Problem:
The columns in the sql you specify in SQLInsert annotation has be ordered in the same way hibernate sorts its properties when constructing the insert sql.
Example:
When WebLogic 9.2 is used the sql should look like this:
"insert into acount (name, address, country) values (?,?,?)"
But when JBoss 4.0.5 is used the sql should look like this:
"insert into acount (address, country, name) values (?,?,?)"
The above are only examples.
Consequence:
I have to have different SQLInsert's for every JEE apllication server we support, because the properties comes in different order depending on the application server used.
Suggested solution:
In the method org.hibernate.cfg.AnnotationBinder.addElementsOfAClass(List<PropertyData> elements, PropertyHolder propertyHolder, boolean isPropertyAnnotated,String propertyAccessor, final XClass annotatedClass, ExtendedMappings mappings)
This property list shown below should be sorted to make sure that the properties also come in the same order:
List<XProperty> properties = annotatedClass.getDeclaredProperties( accessType );
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
18 years
[Hibernate-JIRA] Created: (HHH-3063) Class with @IdClass gets lazy-loaded when "id" field accessed
by Carl Allain (JIRA)
Class with @IdClass gets lazy-loaded when "id" field accessed
-------------------------------------------------------------
Key: HHH-3063
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3063
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.2
Environment: Windows, Postgres
Reporter: Carl Allain
Priority: Minor
When I access the getter named getCountryIsoCode() of the following class (owning a CGLIB proxy that HB gave me), there is some lazy-loading activity that occurs. Of course, the field countryIsoCode is not tagged with @Id, but this is because of the @IdClass annotation, but I would expect the same "will-no-lazy-load-when-only-id-fields-are-accessed" regular behavior.
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.AttributeOverride;
import org.hibernate.annotations.CollectionOfElements;
import javax.persistence.JoinColumn;
import javax.persistence.Column;
import javax.persistence.AttributeOverrides;
import java.io.Serializable;
import java.util.List;
import javax.persistence.ManyToOne;
import com.magrit.bdom.types.multilingual.I18nDescriptionPdo;
import org.hibernate.annotations.FetchMode;
import com.dom.systemconfiguration.entity.SpokenLanguagePdo;
import javax.persistence.Version;
import org.hibernate.annotations.Fetch;
import javax.persistence.Table;
import javax.persistence.Id;
import com.dom.geography.entity.CountrySubdivisionPdo.PrimaryKey;
import javax.persistence.JoinTable;
import javax.persistence.Embedded;
import javax.persistence.OneToMany;
import javax.persistence.IdClass;
import javax.persistence.JoinColumns;
import org.hibernate.annotations.Filter;
import java.util.ArrayList;
import org.hibernate.annotations.BatchSize;
@Entity
@Table(name="PLGE_CTRSD")
@IdClass(com.dom.geography.entity.CountrySubdivisionPdo.PrimaryKey.class)
@BatchSize(size=20)
public class CountrySubdivisionPdo implements Serializable {
public static class PrimaryKey implements Serializable {
// COLUMN: CTRSD_CD
/**
* The "ISO Code" value.
*/
private String code;
// COLUMN: CTR_ISO_CD
/**
* The "Country" value.
*/
private String countryIsoCode;
// COLUMN: CTRSD_CD
/**
* Gets the "ISO Code" value.
*/
@Column(name="CTRSD_CD", nullable=false)
public String getCode() {
return this.code;
}
// COLUMN: CTRSD_CD
/**
* Sets the "ISO Code" value.
*/
public void setCode(String code) {
this.code = code;
}
// COLUMN: CTR_ISO_CD
/**
* Gets the "Country" value.
*/
@Column(name="CTR_ISO_CD", nullable=false)
public String getCountryIsoCode() {
return this.countryIsoCode;
}
// COLUMN: CTR_ISO_CD
/**
* Sets the "Country" value.
*/
public void setCountryIsoCode(String countryIsoCode) {
this.countryIsoCode = countryIsoCode;
}
public boolean equals(Object o) {
if (o instanceof PrimaryKey) {
PrimaryKey other = (PrimaryKey) o;
return (
true // This is just because of the generation algorithm
&&
(
(this.getCode() == null && other.getCode() == null) ||
(this.getCode() != null && other.getCode() != null &&
this.getCode().equals(other.getCode()))
)
&&
(
(this.getCountryIsoCode() == null && other.getCountryIsoCode() == null) ||
(this.getCountryIsoCode() != null && other.getCountryIsoCode() != null &&
this.getCountryIsoCode().equals(other.getCountryIsoCode()))
)
);
}
return false;
}
}
// FK: PLGE_CTRSDLNG_FK_PLGE_CTRSD (TO)
private List<SpokenLanguagePdo> spokenLanguages;
// FK: PLGE_CTRSDTMZ_FK_PLGE_CTRSD (TO)
private List<TimezonePdo> timezones;
// FK: PLGE_CTRSD_FK_PLGE_CTR (FROM) / COLUMN(S): CTR_ISO_CD
private CountryPdo country;
// COLUMN: CTRSD_CD
/**
* The "ISO Code" value.
*/
private String code;
// COLUMN: CTR_ISO_CD
/**
* The "Country" value.
*/
private String countryIsoCode;
// MultilingualDescription BOJ
private List<I18nDescriptionPdo> descriptions;
// TS COLUMN: CTRSD_TS
private Integer revisionNumber;
// FK: PLGE_CTRSDLNG_FK_PLGE_CTRSD (TO)
@OneToMany(targetEntity=SpokenLanguagePdo.class)
@JoinTable(name="PLGE_CTRSDLNG",
joinColumns={ @JoinColumn(name = "CTR_ISO_CD", referencedColumnName = "CTR_ISO_CD"), @JoinColumn(name = "CTRSD_CD", referencedColumnName = "CTRSD_CD") },
inverseJoinColumns={ @JoinColumn(name = "SPLNG_ISO_CD", referencedColumnName = "SPLNG_ISO_CD") }
)
@Fetch(FetchMode.SUBSELECT)
public List<SpokenLanguagePdo> getSpokenLanguages() {
return this.spokenLanguages;
}
// FK: PLGE_CTRSDLNG_FK_PLGE_CTRSD (TO)
public void setSpokenLanguages(List<SpokenLanguagePdo> spokenLanguages) {
this.spokenLanguages = spokenLanguages;
}
// FK: PLGE_CTRSDLNG_FK_PLGE_CTRSD (TO)
/**
* Convenience method. This method is not thread safe.
*/
public void addSpokenLanguage(SpokenLanguagePdo spokenLanguagePdo) {
if (this.spokenLanguages == null) {
this.spokenLanguages = new ArrayList<com.dom.systemconfiguration.entity.SpokenLanguagePdo>();
}
this.spokenLanguages.add(spokenLanguagePdo);
}
// FK: PLGE_CTRSDTMZ_FK_PLGE_CTRSD (TO)
@OneToMany(targetEntity=TimezonePdo.class)
@JoinTable(name="PLGE_CTRSDTMZ",
joinColumns={ @JoinColumn(name = "CTR_ISO_CD", referencedColumnName = "CTR_ISO_CD"), @JoinColumn(name = "CTRSD_CD", referencedColumnName = "CTRSD_CD") },
inverseJoinColumns={ @JoinColumn(name = "TMZ_UID", referencedColumnName = "TMZ_UID") }
)
@Fetch(FetchMode.SUBSELECT)
public List<TimezonePdo> getTimezones() {
return this.timezones;
}
// FK: PLGE_CTRSDTMZ_FK_PLGE_CTRSD (TO)
public void setTimezones(List<TimezonePdo> timezones) {
this.timezones = timezones;
}
// FK: PLGE_CTRSDTMZ_FK_PLGE_CTRSD (TO)
/**
* Convenience method. This method is not thread safe.
*/
public void addTimezone(TimezonePdo timezonePdo) {
if (this.timezones == null) {
this.timezones = new ArrayList<com.dom.geography.entity.TimezonePdo>();
}
this.timezones.add(timezonePdo);
}
// FK: PLGE_CTRSD_FK_PLGE_CTR (FROM) / COLUMN(S): CTR_ISO_CD
@ManyToOne(fetch=FetchType.LAZY, optional=false)
@JoinColumns({
@JoinColumn(name="CTR_ISO_CD", referencedColumnName="CTR_ISO_CD")
})
public CountryPdo getCountry() {
return this.country;
}
// FK: PLGE_CTRSD_FK_PLGE_CTR (FROM) / COLUMN(S): CTR_ISO_CD
public void setCountry(CountryPdo country) {
this.country = country;
}
// COLUMN: CTRSD_CD
/**
* Gets the "ISO Code" value.
*/
// columnDo.getDomain(): {<class:Domain>;id=ALPHANUMERICUPPER$;sqlDataTypeName=VARCHAR;desc=Alphabetic/Numeric - upper ([A9]*);length=null;scale=-1;typeDef=0}
@Id
public String getCode() {
return this.code;
}
// COLUMN: CTRSD_CD
/**
* Sets the "ISO Code" value.
*/
public void setCode(String code) {
this.code = code;
}
// COLUMN: CTR_ISO_CD
/**
* Gets the "Country" value.
*/
// columnDo.getDomain(): {<class:Domain>;id=ALPHABETICUPPER$;sqlDataTypeName=VARCHAR;desc=Alphabetic - upper ([A]*);length=null;scale=-1;typeDef=0}
@Id
public String getCountryIsoCode() {
return this.countryIsoCode;
}
// COLUMN: CTR_ISO_CD
/**
* Sets the "Country" value.
*/
public void setCountryIsoCode(String countryIsoCode) {
this.countryIsoCode = countryIsoCode;
}
// MultilingualDescription BOJ
@CollectionOfElements
@JoinTable(
name="PLGE_CTRSD1",
joinColumns= {
@JoinColumn(name="CTRSD_CD", referencedColumnName="CTRSD_CD"),
@JoinColumn(name="CTR_ISO_CD", referencedColumnName="CTR_ISO_CD")
}
)
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "element.languageCode", column=@Column(name="LNG_CD")),
@AttributeOverride(name = "element.description", column=@Column(name="CTRSD_DES")),
@AttributeOverride(name = "element.descriptionKey", column=@Column(name="CTRSD_DES_CLE"))
})
@Filter(name="GLOBAL_unilingualDescription", condition="LNG_CD = :languageCode")
@Fetch(FetchMode.SUBSELECT)
public List<I18nDescriptionPdo> getDescriptions() {
return this.descriptions;
}
// MultilingualDescription BOJ
public void setDescriptions(List<I18nDescriptionPdo> descriptions) {
this.descriptions = descriptions;
}
// MultilingualDescription BOJ
/**
* Convenience method. This method is not thread safe.
*/
public void addDescription(I18nDescriptionPdo i18nDescriptionPdo) {
if (this.descriptions == null) {
this.descriptions = new ArrayList<com.magrit.bdom.types.multilingual.I18nDescriptionPdo>();
}
this.descriptions.add(i18nDescriptionPdo);
}
// TS COLUMN: CTRSD_TS
@Version
@Column(name="CTRSD_TS", nullable=false)
public Integer getRevisionNumber() {
return this.revisionNumber;
}
// TS COLUMN: CTRSD_TS
public void setRevisionNumber(Integer revisionNumber) {
this.revisionNumber = revisionNumber;
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
18 years
[Hibernate-JIRA] Created: (HHH-3108) <load-collection role="entity_name.property"> doesn't work
by Marcin Mościcki (JIRA)
<load-collection role="entity_name.property"> doesn't work
----------------------------------------------------------
Key: HHH-3108
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3108
Project: Hibernate3
Issue Type: Bug
Components: metamodel
Affects Versions: 3.2.6
Environment: Hibernate 3.2.6, Oracle 9 (insignificant)
Reporter: Marcin Mościcki
Priority: Minor
I use an <sql-query> for a <loader> in a collection owned by a named entity. The role attribute is set to "<entity-name>.<property-name>" - exactly the key under witch the collection's meta data is registered in SessionFactoryImpl.collectionPersisters map - but when the query is being added, SessionFactoryImpl looks for it under the key "<package>.<entity-name>.<property-name>" in this map, and doesn't find it.
When entity-name attribute is removed from the entity mapping and unqualified class name is used to refer to it instead, everything works fine.
The easiest, and probably most uniform solution would be to introduce a second attribute "entity-role" to the load-collection element.
The following exception results from mapping:
<hibernate-mapping package="hibernatedemo.model">
....
<class table="persons_test" entity-name="person" name="Person">
....
<set name="personMap" inverse="true">
<key/>
<one-to-many entity-name="person_map"/>
<loader query-ref="fetch_person_map_by_person"/>
</set>
</class>
<sql-query name="fetch_person_map_by_person">
<load-collection alias="map" role="person.personMap" />
select {map.*} from persons_map_test map where map.person_id=:id
</sql-query>
org.hibernate.MappingException: Unknown collection role: hibernatedemo.model.person.personMap
at org.hibernate.impl.SessionFactoryImpl.getCollectionPersister(SessionFactoryImpl.java:558)
at org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.addCollection(SQLQueryReturnProcessor.java:370)
at org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.processCollectionReturn(SQLQueryReturnProcessor.java:405)
at org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.processReturn(SQLQueryReturnProcessor.java:335)
at org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.process(SQLQueryReturnProcessor.java:148)
at org.hibernate.loader.custom.sql.SQLCustomQuery.<init>(SQLCustomQuery.java:64)
at org.hibernate.engine.query.NativeSQLQueryPlan.<init>(NativeSQLQueryPlan.java:43)
at org.hibernate.engine.query.QueryPlanCache.getNativeSQLQueryPlan(QueryPlanCache.java:114)
at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:446)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:352)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
at hibernatedemo.Test.getHibernateSession(Test.java:44)
at hibernatedemo.Test.main(Test.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
18 years