Hi,
I'd like to know 2 simple things about embedded objects containing only one persisted field:
1. Is is possible to access a custom type (marked as embeddable) value via its name instead of the field's name it contains using HQL ?
For instance:
Code:
@Embeddable
public class Text {
public String value;
// ... some not persisted fields
}
Using a HQL query like:
Code:
"from Foo f where f.textField = 'plop'"
Instead of:
Code:
"from Foo f where f.textField.value = 'plop'"
2. Is it possible to ask hibernate to automatically map the embedded Text.value column name to the name of the field using it or even better, to remove the @Embedded ?
For instance:
Code:
@Entity
public class TextUser {
...
Text getMytext() {
return mytext;
}
}
Instead of:
Code:
@Entity
public class TextUser {
...
@Embedded
@AttributeOverride(name = "value", column = @Column(name = "mytext"))
Text getMytext() {
return mytext;
}
}
I'm open to any suggestions / advice!
Cheers,
Fred