[hibernate-issues] [Hibernate-JIRA] Created: (HHH-4477) DiscriminatorValue could be used in WHERE Statement in OneToMany Joins to Speed up the Result
Robert Bartl (JIRA)
noreply at atlassian.com
Tue Oct 6 16:03:56 EDT 2009
DiscriminatorValue could be used in WHERE Statement in OneToMany Joins to Speed up the Result
---------------------------------------------------------------------------------------------
Key: HHH-4477
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4477
Project: Hibernate Core
Issue Type: Improvement
Affects Versions: 3.3.1
Reporter: Robert Bartl
Currently the DiscriminatorValue is not used in Queries that fetch multiple Entities.
Adding this could increase the Speed of the Fetch as another index could be used.
Example:
@Entity(name="Issues")
public class Issue
{
@Id
@Column(nullable = false, insertable = true, updatable = false)
private int id;
@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY,mappedBy="objectId")
private List<TicketTransaction> transactions;
public List<TicketTransaction> getTransactions()
{
return transactions;
}
}
@Entity(name = "Transactions")
@Table(name = "Transactions")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "ObjectType", discriminatorType = DiscriminatorType.STRING, length = 20)
@DiscriminatorValue("null")
public abstract class Transaction {
@Id
@Column(nullable = false, insertable = true, updatable = false)
private int id;
}
@DiscriminatorValue("Issue")
@Entity
public final class TicketTransaction extends Transaction {
@Column(nullable = true, insertable = false, updatable = false, name = "ObjectId")
private int objectId;
}
ObjectId is in ticketTransaction class because of HBX-1075 Bug, should have been in Transaction class.
This setup results in the following Query if Issue.getTransactions() is called:
select transactio0_.ObjectId as ObjectId1_, transactio0_.id as id1_, transactio0_.ObjectType as ObjectType4_0_, transactio0_.ObjectId as ObjectId4_0_ from Transactions transactio0_ where transactio0_.ObjectId=4236
missing: "AND ObjectType = 'Issue'"
--
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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list