[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
[Hibernate-JIRA] Created: (HHH-4095) bug in org.hibernate.Hibernate.createBlob( InputStream in )
by Stephan Schröder (JIRA)
bug in org.hibernate.Hibernate.createBlob( InputStream in )
-----------------------------------------------------------
Key: HHH-4095
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4095
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.2
Environment: (doesn't matter because ii's just a plain wrong usage of the InputStream.available-mehtode but anyway:) Hibernate. 3.3.2, Hsqldb1.8
Reporter: Stephan Schröder
Priority: Minor
The implementation of org.hibernate.Hibernate.createBlob( InputStream in ) looks like this
public static Blob createBlob(InputStream stream) throws IOException {
return new SerializableBlob( new BlobImpl( stream, stream.available() ) );
}
The second parameter here is supposed to be the length of the inputstream. The problem is that stream.available() doesn't return the length of the inputstream. That's explicitly noted in the Java-API (http://java.sun.com/javase/6/docs/api/java/io/InputStream.html#available):
"Note that while some implementations of InputStream will return the total number of bytes in the stream (on calling available() ), many will not. It is never correct to use the return value of this method to allocate a buffer intended to hold all data in this stream."
This is the source of my problem, only the first available bytes are read out of the inputstream. While the workaround for me is to simply call org.hibernate.Hibernate.createBlob( InputStream in,int length ), the misuse of stream.available() in Hibernate.createBlob( InputStream in ) remains to be resolved.
Solution: the only way to get the length of an InputStream ist to read it completly, if you don't want to do that Hibernate.createBlob( InputStream i ) should be removed.
(By the way, why is length of type int? java.io.File.length() and java.sql.Blob.length() are of type long, so length should be of type long as well).
--
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
[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
[Hibernate-JIRA] Created: (BVAL-175) validateValue incorrectly reports java.lang.IllegalArgumentException: Invalid property path. There is no property listOfString in entity simple_bv_servlet.Person
by Ed Burns (JIRA)
validateValue incorrectly reports java.lang.IllegalArgumentException: Invalid property path. There is no property listOfString in entity simple_bv_servlet.Person
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: BVAL-175
URL: http://opensource.atlassian.com/projects/hibernate/browse/BVAL-175
Project: Bean Validation
Issue Type: Bug
Affects Versions: 4.0.0.Alpha2
Environment: HEAD of JSR-303 RI
Reporter: Ed Burns
Calling validator.validateValue() seems to fail when it shouldn't.
Consider this pojo:
8<----------------------------------
package simple_bv_servlet;
import java.util.List;
import javax.validation.constraints.NotNull;
public class Person {
@NotNull
private String firstName;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
@NotNull
private String lastName;
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
private List<String> listOfString;
public List<String> getListOfString() {
return listOfString;
}
public void setListOfString(List<String> listOfString) {
this.listOfString = listOfString;
}
}
8<----------------------------
And consider this selvlet which validates this pojo in its doGet() impl.
8<--------------------------------------
package simple_bv_servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.ValidatorContext;
import javax.validation.ValidatorFactory;
public class SimpleBVServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
PrintWriter out = resp.getWriter();
resp.setContentType("text/html");
out.print("<html><head><title>SimpleBVServlet</title></head><body>");
ValidatorFactory validatorFactory = null;
validatorFactory = Validation.buildDefaultValidatorFactory();
out.print("<p>");
out.print("Obtained ValidatorFactory: " + validatorFactory + ".");
out.print("</p>");
ValidatorContext validatorContext = validatorFactory.usingContext();
javax.validation.Validator beanValidator = validatorContext.getValidator();
out.print("<h1>");
out.print("Validating invalid person class using validateValue.");
out.print("</h1>");
List<String> value = new ArrayList<String>();
value.add("one");
value.add("two");
value.add("three");
Set<ConstraintViolation<Person>> violations =
beanValidator.validateValue(Person.class, "listOfString", value);
if (violations.isEmpty()) {
out.print("<p>");
out.print("No ConstraintViolations found.");
out.print("</p>");
} else {
for (ConstraintViolation<Person> curViolation : violations) {
out.print("<p>");
out.print("ConstraintViolation: message: " + curViolation.getMessage() +
" propertyPath: " + curViolation.getPropertyPath());
out.print("</p>");
}
}
Person person = new Person();
out.print("<h1>");
out.print("Validating invalid person instance using validate.");
out.print("</h1>");
violations = beanValidator.validate(person);
if (violations.isEmpty()) {
out.print("<p>");
out.print("No ConstraintViolations found.");
out.print("</p>");
} else {
for (ConstraintViolation<Person> curViolation : violations) {
out.print("<p>");
out.print("ConstraintViolation: message: " + curViolation.getMessage() +
" propertyPath: " + curViolation.getPropertyPath());
out.print("</p>");
}
}
out.print("<h1>");
out.print("Validating valid person.");
out.print("</h1>");
person.setFirstName("John");
person.setLastName("Yaya");
violations = beanValidator.validate(person);
if (violations.isEmpty()) {
out.print("<p>");
out.print("No ConstraintViolations found.");
out.print("</p>");
} else {
for (ConstraintViolation<Person> curViolation : violations) {
out.print("<p>");
out.print("ConstraintViolation: message: " + curViolation.getMessage() +
" propertyPath: " + curViolation.getPropertyPath());
out.print("</p>");
}
}
out.print("</body></html>");
}
}
8<------------------------
The call to
Set<ConstraintViolation<Person>> violations =
beanValidator.validateValue(Person.class, "listOfString", value);
causes this exception to be thrown:
java.lang.IllegalArgumentException: Invalid property path. There is no property listOfString in entity simple_bv_servlet.Person
But I say, doch, there is such a property on the Person.
This is new behavior in 4.0.0.Beta2, and it's breaking Glassfish.
Thanks,
Ed
--
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
[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