[Hibernate-JIRA] Created: (ANN-794) Polymorphic query on abstract function
by radu (JIRA)
Polymorphic query on abstract function
--------------------------------------
Key: ANN-794
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-794
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.3.0.ga
Reporter: radu
Priority: Blocker
I have the following classes adnnotated with hibernate:
<pre><code>
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public abstract class Symbol
implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
@AccessType("property")
public abstract String getCode();
@AccessType("property")
public abstract void setCode(String code);
}
@javax.persistence.Entity
@AttributeOverride( name="code", column = @Column(name="field1") )
public class Child1 extends Symbol {
@Basic
@Column(nullable = false)
private String field1;
@AccessType("property")
public String getCode() {
return getField1();
}
@AccessType("property")
public void setCode(String code) {
setField1(code);
}
public void setField1(String field1) {
this.field1 = field1;
}
public String getField1() {
return field1;
}
}
@javax.persistence.Entity
@AttributeOverride( name="code", column = @Column(name="field2") )
public class Child2 extends Symbol {
@Basic
@Column(nullable = false)
private String field2;
@AccessType("property")
public String getCode() {
return getField2();
}
@AccessType("property")
public void setCode(String code) {
setField1(code);
}
public void setField1(String field2) {
this.field2 = field2;
}
public String getField2() {
return field2;
}
}
</code></pre>
As objectual rules about polymorphisms the following query should be valid and to retrieve correct field value:
session.createQuery("from Symbol s where s.code = :code");
but it give me the error:
org.hibernate.QueryException: could not resolve property: code of: ...
Please give some advices how to work around this problem if this situation does not follow hibernate concept or JPA specs and is not possible to implement it.
Idea is that it should be possible to work at hight level without changing database or existing classes.
Thanks
--
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
15 years, 2 months
[Hibernate-JIRA] Created: (HHH-2967) Cast to date in Formula still doesn't work
by Frederic Leitenberger (JIRA)
Cast to date in Formula still doesn't work
------------------------------------------
Key: HHH-2967
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2967
Project: Hibernate3
Issue Type: Bug
Components: query-criteria, query-hql, query-sql
Affects Versions: 3.2.5
Environment: Hibernate-Version: 3.2.5.ga
Oracle 9i/10g
Reporter: Frederic Leitenberger
Priority: Minor
Similar to HHH-473.
Oracle 10g supports trunc(TS). (TS is a timestamp)
Oracle 9i only supports trunc(cast(TS as date)) [and 10g supports this still too].
Therefore i need to add the cast to the Forumla.
@Basic
@Column(nullable = false, updatable = false)
@Temporal(TemporalType.TIMESTAMP)
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
@Formula(value = "trunc(cast(created as date))")
public Date getDate() {
return date
}
public void setDate(Date date {
this.date= date
}
This results in the following query:
select
eventlog0_.id as id9_0_,
eventlog0_.created as created9_0_,
.........
trunc(cast(eventlog0_.created as eventlog0_.date)) as formula6_0_
from
ICCS6.EventLog eventlog0_
where
eventlog0_.id=?
The alias in front of "date" is obviously misplaced there.
I also tried renaming the formula (since it was called "date"), but this didn't change the result.
--
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
15 years, 3 months
[Hibernate-JIRA] Created: (ANN-825) TestCase could check for superclass of Dialect before skipping it
by Juraci Paixao Krohling (JIRA)
TestCase could check for superclass of Dialect before skipping it
-----------------------------------------------------------------
Key: ANN-825
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-825
Project: Hibernate Annotations
Issue Type: Improvement
Reporter: Juraci Paixao Krohling
Assignee: Hardy Ferentschik
Attachments: ANN-CheckSuperclassDialectsBeforeSkip.diff
If a subclass of org.hibernate.test.annotations.TestCase is annotated with @RequiresDialect (or any of its methods), TestCase tries to match the exact name of the dialect in order to decide to skip it or not.
My suggestion (and the attached patch) adds another check. If I specify the superclass of a set of dialects (like Oracle8iDialect, which is superclass of Oracle9i and Oracle10g), the test won't skip the subclasses of Oracle8iDialect.
How to reproduce:
1) Create a test case annotated with @RequiresDialect(Oracle8iDialect.class)
2) Configure the test to run using the Oracle9iDialect
3) The test will be skipped, even though Oracle9iDialect is a subclass of Oracle8iDialect
After the patch, the step 3 would be:
3) The test is not skipped.
If there's a reason to not check the superclasses, please reject this JIRA. Otherwise, please review it and commit (or assign it back to me to commit).
--
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
15 years, 3 months
[Hibernate-JIRA] Created: (ANN-593) Ability for an @NamedQuery on a @MappedSuperclass to be copied up to the subclass
by John Newman (JIRA)
Ability for an @NamedQuery on a @MappedSuperclass to be copied up to the subclass
---------------------------------------------------------------------------------
Key: ANN-593
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-593
Project: Hibernate Annotations
Issue Type: Improvement
Components: binder
Affects Versions: 3.2.1
Environment: INFO Version:15 - Hibernate Annotations 3.2.1.GA
09:15:01,755 INFO Environment:500 - Hibernate 3.2.1
INFO SettingsFactory:81 - RDBMS: Microsoft SQL Server, version: 08.00.0760
09:15:06,114 INFO SettingsFactory:82 - JDBC driver: jTDS Type 4 JDBC Driver for MS SQL Server and Sybase, version: 1.2
09:15:06,255 INFO Dialect:151 - Using dialect: org.hibernate.dialect.SQLServerDialect
Reporter: John Newman
If I use a @MappedSuperclass (which is a very useful annotation btw) I have to manually copy any queries I want with taht class up to all subclasses. The binder should check any mapped superclasses and pull those named queries up. i.e.
/**
* Base User class that different projects user classes derive from.
* Hibernate annotations doesn't pick up that query, so you have to copy it up to your subclass
*/
@MappedSuperclass
@NamedQueries({
@NamedQuery(name="User.findByLoginName",
query="FROM User WHERE loginName = ?") // this is useless down here, i just put it here for reference
})
public class BaseUser<PK extends Serializable> extends IdEntity<PK> {
private static final long serialVersionUID = -4443522925041212381L;
protected String loginName;
@Column(unique=true)
public String getLoginName() {
return this.loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName;
}
}
/**
* Custom user class for a certain application
*/
@Entity
@Table(name="tbl_user")
@GenericGenerator(name=IdGen.NAME, strategy=IdGen.AUTO)
@NamedQueries({
@NamedQuery(name="User.findByLoginName",
query="FROM User WHERE loginName = ?") // had to copy this up from the base class
})
public class User extends BaseUser<Short> {
private static final long serialVersionUID = -6199544722824321999L;
private String firstName;
...
}
so in short it would be nice if the scanner would check for that and bind any named queries up to the subclass
--
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
15 years, 3 months