[Hibernate-JIRA] Created: (HCANN-28) Polymorphic Query on named field using @Inheritance(strategy=InheritanceType.JOINED)
by Sean Tozer (JIRA)
Polymorphic Query on named field using @Inheritance(strategy=InheritanceType.JOINED)
------------------------------------------------------------------------------------
Key: HCANN-28
URL: http://opensource.atlassian.com/projects/hibernate/browse/HCANN-28
Project: Hibernate Commons Annotations
Issue Type: Bug
Affects Versions: 3.2.0
Reporter: Sean Tozer
Using a Joined table strategy and annotation definitions, Hibernate does not respect the name parameter from a column annotation, as in @Column(name = "ES_CELL_LINE"), in the generation of a polymorphic query on the parent type.
@Entity
@Table(name = "GENOTYPE")
@Inheritance(strategy=InheritanceType.JOINED)
public class Genotype implements java.io.Serializable {
private int genotypeKey;
...
}
@Entity
@Table(name = "GENOTYPE_TARGETED")
public class GenotypeTargeted extends Genotype {
private String ESCellLine;
@Column(name = "ES_CELL_LINE", length = 32)
@Length(max = 32)
public void setESCellLine(String eSCellLine) {
ESCellLine = eSCellLine;
}
public String getESCellLine() {
return ESCellLine;
}
}
Using the query "select distinct g from Genotype g" produces a query containing "genotype4_1_.ESCellLine as ESCellLine69_3_," rather than "genotype4_1_.ES_CELL_LINE as ESCellLine69_3_," as would be expected. All named fields from the parent class are correct, while all named fields from the subclasses use the field name rather than the value of the name parameter.
--
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
14 years, 5 months
[Hibernate-JIRA] Created: (ANN-756) @Column annotation ignored when placed on entity's @Id property
by sagi mann (JIRA)
@Column annotation ignored when placed on entity's @Id property
---------------------------------------------------------------
Key: ANN-756
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-756
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.3.1.GA
Environment: hib core 3.2.6, my sql 5
Reporter: sagi mann
Hibernate docs specify that when using a compound key class, a Hibernate optional feature is to place @Column annotations within the key class. The observed behavior is that Hibernate ignores @Column if placed ANYWHERE ELSE, for example, on the entity's ID properties. In other words, the standard JPA way of annotating ID fields is not working under Hibernate, and the "optional" feature is mandatory.
Example how to reproduce (see comments inside the code regarding the inconsistency above). Accessors were omitted for clarity:
// the identity class
@Entity
public class SecurityIdentity implements Serializable {
public SecurityIdentity() {}
@Id
@Column(name="IDENTITY_ID")
@GeneratedValue
public Long getId() ...
@Column(name="IDENTITY_NAME")
public String getName() ...
@Override public boolean equals(Object o) ...
@Override public int hashCode() ...
}
// the domain class
@Entity
public class SecurityDomain implements Serializable {
public SecurityDomain() {}
@Id
@Column(name="DOMAIN_ID")
@GeneratedValue
public Long getId() ...
@Column(name="DOMAIN_NAME")
public String getName() ...
@Override public boolean equals(Object o) ...
@Override public int hashCode() ...
}
// the domain-identity mapping class
@Entity
@IdClass(pu1.DomainIdentityPK.class)
public class DomainIdentity implements Serializable {
public DomainIdentity() {}
@Id
public Long getDomainId() ...
@Id
public String getUserAlias() ...
@ManyToOne
@JoinColumn(name="IDENTITY_ID")
public SecurityIdentity getSecurityIdentity() ...
@ManyToOne
@JoinColumn(name="DOMAIN_ID", insertable=false, updatable=false)
public SecurityDomain getSecurityDomain() { return securityDomain; }
public void setSecurityDomain(SecurityDomain securityDomain) {
this.securityDomain = securityDomain;
this.domainId = (securityDomain != null ? securityDomain.getId() : null);
}
private SecurityDomain securityDomain;
}
// the map key class
public class DomainIdentityPK implements Serializable {
public DomainIdentityPK() {
}
/********* @Column inconsistency - cannot be placed inside the entity - only inside the PK class *******/
@Column(name="DOMAIN_ID")
public Long getDomainId() ...
[b]@Column(name="ALIAS")[/b]
public String getUserAlias() ...
public boolean equals(Object o) ...
public int hashCode() ...
}
--
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
14 years, 5 months
[Hibernate-JIRA] Commented: (HHH-1395) Hierarchical entity data management using 'modified preorder tree traversal algorithm' (nested set trees)
by Billworth Vandory (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1395?page=c... ]
Billworth Vandory commented on HHH-1395:
----------------------------------------
i had a look at the code attachment. If hashcode() is implemented using the id, then the tree will break while its being persisted. There's also an n+1 problem unless you fetch join the children which results in duplicate rows being returned by the query - not severe since the query is a throw away, but it seems to break the resultset transformer. I'd like to raise a question whether this could be implemented without the adjacency list, and make the getchildren() transient and build the traversal pathway ahead of time. That would remove the self join, and a dependency on the adjacency list model.
very promising though, a great start
> Hierarchical entity data management using 'modified preorder tree traversal algorithm' (nested set trees)
> ----------------------------------------------------------------------------------------------------------
>
> Key: HHH-1395
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1395
> Project: Hibernate Core
> Issue Type: New Feature
> Components: core, query-hql
> Environment: Hibernate 3.1 plus Annotations extending EJB3 implementation
> Reporter: James Salt
> Attachments: nestedset.tar.gz, utils-parent-20091117.tar.gz
>
> Original Estimate: 168h
> Remaining Estimate: 168h
>
> An enhancement to allow entities to exist in a managed tree (DAG) structure, via the use of property annotations and entity annotations. With an extension to the HQL language to mimic the Oracle recusive query clause.
> This would be classically be useful for Bill of Material uses, or any tree like entity structure.
> I have implemented a homebrew approach using the 'adjacency list method' , and a post persist call back method to set the node path. Although I think a more full blown optimised algorithm would be the 'modified preorder tree traversal algorithm'.
> In the annotations world this could be implemented using an annotation like @Hierarchical to the entity, with a @Parent (mask for @ManyToOne) annotation on the parent field/parameter and @Children (mask for @OneToMany) annotation on the list of children entities.
> Then a postupdate method could be implemented for the entity type, that recalculates the tree meta data -i.e. parent, left and right.
> I believe this would be a valuable extension (useful for many common data models) to the hibernate core product that could be exposed through annotations as I have discussed and the hbm.xml.
> The users of such a system would be aware of the performance implications on insert/update/delete, but gain a massive performance gain on querying a tree data model.
>
--
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
14 years, 5 months
[Hibernate-JIRA] Commented: (HHH-1513) Duplicated entities in a one-to-many select
by Brad Davis (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1513?page=c... ]
Brad Davis commented on HHH-1513:
---------------------------------
I've discovered an issue where an HQL query with two 'left join fetch' statements also triggers duplicated entities. Is this considered to be covered under this same bug or would this be considered a separate issue? Also, if you're going to say something is a FAQ it would be nice to have a pointer to said FAQ, especially now that the hibernate FAQ as a whole has dropped off the face of the earth.
> Duplicated entities in a one-to-many select
> -------------------------------------------
>
> Key: HHH-1513
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1513
> Project: Hibernate Core
> Issue Type: Bug
> Components: query-criteria
> Affects Versions: 3.0.5, 3.1.2
> Environment: Oracle
> Reporter: Tiago Rinck Caveden
> Priority: Minor
> Attachments: mappings.zip
>
>
> Using a criteria to obtain a full select on an class that has a one-to-many eager property returns duplicated entities.
> It seems it's making the returned list to have the same size of the result set returned by the join necessary to fetch the rows.
> Here's the code I'm executing:
> Session sessao = getSession();
> try {
> Criteria criterio = sessao.createCriteria(TipoErro.class);
> return criterio.list();
> } finally {
> releaseSession(sessao);
> }
> And here's the mapping of the one-to-many property:
> <set name="emailsNotificacao" inverse="true" lazy="false" fetch="join">
> <key column="ID_TIPO_ERRO" not-null="true" />
> <one-to-many
> class="com.matera.inss.entity.EmailNotificacao" />
> </set>
> I'll attach both the mapping of the parent entity, and of the child entity (don't know if it might help).
> Changing the use of the criteria by a find("from TipoErro") works perfectly.
> There's already a topic opened on the forum about this same issue, with more details and examples.
> Here's the topic: http://forum.hibernate.org/viewtopic.php?t=955186
> Thank you very much,
> Tiago.
--
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
14 years, 5 months
[Hibernate-JIRA] Created: (HHH-2608) allow delete-orphan cascade style in one-to-one mapping
by Joe Kelly (JIRA)
allow delete-orphan cascade style in one-to-one mapping
-------------------------------------------------------
Key: HHH-2608
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2608
Project: Hibernate3
Issue Type: New Feature
Components: core
Affects Versions: 3.2.4
Environment: 3.2.4, DB2 v8
Reporter: Joe Kelly
Please allow the cascade-style "delete-orphan" for one-to-one relationships. When I try to use that cascade style, I get the exception "org.hibernate.MappingException: single-valued associations do not support orphan delete".
I realize that the reference manual says "Note that single valued associations (many-to-one and one-to-one associations) do not support orphan delete." But why? I can think of many cases where you WOULD want parent-child semantics in a one-to-one relationship.
For example, I have encountered some legacy databases where an entity has all of its fields stored in one table EXCEPT for an optional large field (e.g. a blob field) that is stored in another table, presumably for some performance or storage optimization reason. In this case the two tables are joined with a one-to-one relationship, using a shared primary key. Here are some hypothetical tables, classes and mappings that illustrate this example:
company
(
company_id (PK)
name
)
company_extra
(
company_extra_id (PK), (FK referencing company.company_id)
some_extra_info
)
class Company
{
int companyId;
String name;
CompanyExtra companyExtra;
}
class CompanyExtra
{
int companyExtraId;
String someExtraInfo;
Company company;
}
<class name="Company" table="company">
<id name="companyId" column="company_id">
<generator class="sequence">
<param name="sequence">COMPANY_SEQ</param>
</generator>
</id>
<property name="name" column="name" />
<one-to-one name="companyExtra" class="CompanyExtra" cascade="all, delete-orphan" />
</class>
<class name="CompanyExtra" table="company_extra">
<id name="companyExtraId" column="company_extra_id" unsaved-value="null">
<generator class="foreign">
<param name="property">company</param>
</generator>
</id>
<property name="someExtraInfo" column="some_extra_info" />
<one-to-one name="company" class="Company" constrained="true" />
</class>
For the purposes of this example, CompanyExtra is a child of Company and belongs to one and only one instance of Company. It cannot be shared between Company instances and it cannot be an orphan (i.e. it cannot exist without a parent Company). Also, CompanyExtra is optional so you can have a Company without any associated CompanyExtra during Company's lifecycle.
To me, it seems natural and logical that if you set Company.companyExtra to null, and save Company, Hibernate should automatically delete the associated record in the company_extra table if the delete-orphan cascade style is configured (which, of course, it not currently allowed). This is what I want to do when editing an existing Company instance:
aCompany = session.load(...);
aCompany.setCompanyExtra(null);
aCompany.setName("some new name");
session.save(aCompany); // automatically deletes company_extra record
For now, I think the workaround is to explicitly delete the CompanyExtra instance in Java code but that just doesn't seem natural to me and it isn't transparent. I do NOT want to do this:
aCompany = session.load(...);
companyExtra = aCompany.getCompanyExtra(); // ***extra, unnatural method call
aCompany.setCompanyExtra(null);
aCompany.setName("some new name");
session.save(aCompany);
session.delete(companyExtra); // ***another extra, unnatural method call
--
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
14 years, 5 months
[Hibernate-JIRA] Created: (ANN-573) Many-to-many with Attributes (Attribute-class with two @ManyToOne mappings as @Id) not possible
by Christian Köberl (JIRA)
Many-to-many with Attributes (Attribute-class with two @ManyToOne mappings as @Id) not possible
-----------------------------------------------------------------------------------------------
Key: ANN-573
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-573
Project: Hibernate Annotations
Type: Bug
Components: binder
Versions: 3.2.1
Environment: Hibernate+Annotations 3.2.1-ga, HSQLDB 1.8.0.7
Reporter: Christian Köberl
Attachments: manytomanybug.zip
Im trying to map the following relation:
Order 1-n OrderLine m-1 Product
where the OrderLine contains an amount of the ordered product.
The problem seems to be multiple @Id in combination with @ManyToOne:
@Entity
@Table(name = "order_line")
// @IdClass(OrderLinePK.class)
public class OrderLine implements Serializable
{
@Id
@ManyToOne(targetEntity = Order.class)
@JoinColumn(name = "order_id", nullable = false)
private Order order;
@Id
@ManyToOne(targetEntity = Product.class)
@JoinColumn(name = "product_id", nullable = false)
...
}
Hibernate maps the OrderLine class in the following way:
DEBUG SchemaUpdate:149 - create table order_line (product varbinary(255) not null, order varbinary(255) not null, amount integer, primary key (order))
(maybe this relates to http://opensource.atlassian.com/projects/hibernate/browse/ANN-435)
When I add an IdClass to the OrderLine, I get the following exception:
Initial SessionFactory creation failed.org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: model.OrderLine.order in model.Order.lineItems
The example is attached as a runnable Maven2-Project, just run mvn test. The test dao.OrderDaoAnnotationTest fails.
In the project I also tried to map the same classes with hbm-Files and this works (dao.OrderDaoHbmTest).
--
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
14 years, 5 months