I’m using MyEclipse to hibernate reverse engineer a view in an Oracle database.
EDIT: The view has six columns, all varchar types, no unique keys. Also, I don’t have control over the view.
It’s generating three classes:
- Broker
- BrokerID <— why?
- BrokerDAO
Everything works, per se. But why does it create an ID class? I’d like to use a JSON serializer against the Broker class to get the data and send it back to the browser in an AJAX call.
Now when I serialize against Broker, I get:
[{
id: {
field1: "",
field2: ""
}
}, {
id: {
field1: "",
field2: ""
}
}, {
id: {
field1: "",
field2: ""
}
}]
instead of what I really want which is this:
[{
field1: "",
field2: ""
}, {
field1: "",
field2: ""
}, {
field1: "",
field2: ""
}]
Every Hibernate object needs an identifier of some sort.
If you don’t want this generated property to be included in your JSON output, simply filter out the field. Depending on the JSON library used, you may be able to annotate the field with
@JsonIgnoreor something similar – refer to the documentation for the library.