[
http://opensource.atlassian.com/projects/hibernate/browse/ANN-539?page=co...
]
Christophe Vanfleteren commented on ANN-539:
--------------------------------------------
Emmanuel,
I'm not quite sure I quite follow your argument:
I'd use Range<Integer> on the setBounds, as in
Example e = new Example();
Range<Integer> bounds = new Range<Integer>(0,10);
e.setBounds(bounds);
Hibernate can create an instance of Range using newInstance, and it can fill up the
min/max fields of it, it just needs a way to know what type those fields should have when
it hydrates.
If you could do something like this:
@AttributeOverrides({
@AttributeOverride(name="min", column = @Column(name="min_size"),
type=@Type(type="int") ),
@AttributeOverride(name="max", column = @Column(name="max_size"),
type=@Type(type="int") )
})
private Range<Integer> sizeBounds;
@AttributeOverrides({
@AttributeOverride(name="min", column =
@Column(name="min_date"),type=@Type(type="date") ),
@AttributeOverride(name="max", column =
@Column(name="max_date"),type=@Type(type="date") )
})
private Range<Date> dateBounds;
then you'd be able to use the single Range<T> class in the same entity (you
could problably also guess the correct type using the Parameterized types of the fields).
Kind of like you could do when using mapping files (mapping the same class as a component
twice, only using different types for the fields).
As it stands now, you need to make a specialized implementation every time you plan to use
a Range of a different type.
Generics and @Embedded doesn't work
-----------------------------------
Key: ANN-539
URL:
http://opensource.atlassian.com/projects/hibernate/browse/ANN-539
Project: Hibernate Annotations
Type: Bug
Versions: 3.2.1
Environment: Hibernate 3.2.1, Oracle 10XE
Reporter: Christophe Vanfleteren
Attachments: generic.zip
It doesn't seem to be possible to use a plain generic field as a component,
for example:
@Embedded
private Range<Integer> bounds
doesn't work (you get an "org.hibernate.AnnotationException: Property
generic.GenericRange.min has an unbound type and no explicit target entity. Resolve this
Generic usage issue or set an explicit target attribute (eg @OneToMany(target=) or use an
explicit @Type") error.
It does work when you extend the generic class in which you define the type (IntegerRange
extends Range<Integer>)
for example:
@Embedded
private IntegerRange bounds
works
I've attached some classes that demeonstrate this problem. This issue was raised
before in
http://opensource.atlassian.com/projects/hibernate/browse/ANN-406?page=co...,
but was rejected since no testcase was provided.
--
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