[Hibernate-JIRA] Created: (HHH-2787) Criteria Aggregate Projections do not JOIN additional tables on which restrictions apply
by Sami Dalouche (JIRA)
Criteria Aggregate Projections do not JOIN additional tables on which restrictions apply
----------------------------------------------------------------------------------------
Key: HHH-2787
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2787
Project: Hibernate3
Issue Type: Bug
Components: query-criteria
Affects Versions: 3.2.5
Environment: PostgreSQL Dialect
Reporter: Sami Dalouche
Priority: Critical
Hi,
When you have a Criteria Object, on which you :
- Add Aggregate Projections such as rowCount()
- createAlias("whatever").add(Restrictions.*..)
It looks like that the "whatever" table is NOT joined, even though it is joined OK when the projections are not there.
So, here is an approximate Unit test that should throw an exception (I couldn't create a complete test case since I couldn't get the unit tests to run on my machine -any link explaining this step somewhere ?):
Criteria c1 = s.createCriteria(Enrolment.class)
.setProjection( Projections.projectionList().add(Projections.rowCount(), "rowCount") );
Criteria studentCriteria = c1.createAlias("student", "st");
studentCriteria.add(Restrictions.eq("name", "whatevername"));
It should complain saying the "st.name" alias does not exist, because the student class has not been joined.
Regards,
Sami Dalouche
--
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
17 years, 1 month
[Hibernate-JIRA] Created: (ANN-686) SubClass with EmbeddedId or IdClass containing @ManyToOne fail at startup
by Marcos Sousa (JIRA)
SubClass with EmbeddedId or IdClass containing @ManyToOne fail at startup
-------------------------------------------------------------------------
Key: ANN-686
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-686
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.3.1.beta1, 3.3.0.ga
Reporter: Marcos Sousa
Priority: Minor
I subclass Customer that has a EmbeddedId using JOIN inheritance strategy. My embeddable class has @ManyToOne relationship. Look the classes:
Pesson class:
@Entity
@Table(name="person")
public class Person {
@Id
private Integer personId;
private String name;
}
Embeddable class ID.
@Embeddable
public class PersonPk implements Serializable {
@ManyToOne(optional=false,
cascade={CascadeType.PERSIST,
CascadeType.REFRESH,
CascadeType.REMOVE}, fetch=FetchType.EAGER)
@JoinColumn(name="personId")
private Person person;
// ... getters and setters
}
CustomerClass:
@Entity
@Table(name="Customer")
@Inheritance(strategy=InheritanceType.JOINED)
public class Customer {
@Id
private PersonPk pk = new PersonPk();
}
Regional Custumer:
@Entity
@Table(name="AmericanCustomer")
@PrimaryKeyJoinColumn(name="personId")
@IdClass(PessoaPk.class)
public class AmericanCustomer extends Customer {
// some american customer fields..
}
This mapping throw this exception at hibernate startup:
Invocation of init method failed; nested exception is java.util.NoSuchElementException
Caused by:
java.util.NoSuchElementException
at java.util.AbstractList$Itr.next(Unknown Source)
at org.hibernate.util.JoinedIterator.next(JoinedIterator.java:53)
at org.hibernate.cfg.Ejb3JoinColumn.buildJoinColumn(Ejb3JoinColumn.java:210)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:463)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:501)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:282)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:918)
--
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
17 years, 1 month
[Hibernate-JIRA] Created: (ANN-688) Repeated columns created for single table inheritance
by Nick Heudecker (JIRA)
Repeated columns created for single table inheritance
-----------------------------------------------------
Key: ANN-688
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-688
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.3.0.ga
Environment: Hibernate 3.2.5ga, Postgresql
Reporter: Nick Heudecker
I have the following classes:
@Entity
@Inheritance(strategy= InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="cltype", discriminatorType= DiscriminatorType.STRING, length=10)
@DiscriminatorValue("device")
public abstract class Device extends AbstractPersistent {
private System system;
@ManyToOne
public System getSystem() {
return system;
}
public void setSystem(System system) {
this.system = system;
}
}
@Entity
@DiscriminatorValue("snmp")
public class SnmpDevice extends Device {
// .... additional properties defined
}
When I try to create the SessionFactory, I'm getting the following exception:
Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: model.SnmpDevice column: system_uuid (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:652)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:674)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:696)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:450)
at org.hibernate.mapping.SingleTableSubclass.validate(SingleTableSubclass.java:43)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1102)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
--
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
17 years, 1 month
[Hibernate-JIRA] Created: (HHH-2546) fetch="select" doesn't work when there are no mapped columns in joined except <key
by Derar Bakr (JIRA)
fetch="select" doesn't work when there are no mapped columns in joined except <key
----------------------------------------------------------------------------------
Key: HHH-2546
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2546
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.3
Environment: Windows XP Pro
Reporter: Derar Bakr
java.lang.StringIndexOutOfBoundsException: String index out of range: -2
at java.lang.String.substring(String.java:1768)
at java.lang.String.substring(String.java:1735)
at org.hibernate.persister.entity.AbstractEntityPersister.renderSelect(AbstractEntityPersister.java:2899)
at org.hibernate.persister.entity.SingleTableEntityPersister.generateSequentialSelect(SingleTableEntityPersister.java:647)
at org.hibernate.persister.entity.SingleTableEntityPersister.postInstantiate(SingleTableEntityPersister.java:696)
....
Everything is very simple.
There is stupid code in SelectFragment class, method toFragmentString, line 94. String that is being created there, contains list of fields, like a "f1, f2, f3, ..., fn".
", " is being added in every iteration, without check for it is first iteration.
And in class AbstractEntityPersister., method renderSelect, line 2899, where that method is called, this first ", " is deleted using substring(2). So no check for empty string.
I suggest to add check :)))
I just create dynamic mappings programmatically, so create empty join subclass mappings - and in created table there are no fields by default except foreing key.
--
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
17 years, 2 months