Pouzivam toto z konference EJB3 na jboss.org:dsouza, The bug has been resolved (not yet solved), so i would expect that a sollution is provided within the next week.
I've done the following work arround so that i can still use Enums:
I've added a constructor to te enum wich can contain a int value :
| public enum Scope implements Serializable {
|
| PUBLIC(0),
| PROTECTED(1),
| PRIVATE(2);
|
| private int type = 0;
|
| private Scope(int type) {
| this.type = type;
| }
|
| public int getType() {
| return type;
| }
|
| }
|
And i made the following changes to the entity:
I've made the get/set method with the enum @Transient so that it is not stored in the database. Then i created a new set of get/set methods:
| public class MyEntity implements java.io.Serializable {
|
| private Scope scope = Scope.PUBLIC;
|
| ...
|
| public void setScopeType(int scopeType) {
| for (Scope scope : Scope.values()) {
| if (scope.getType() == scopeType) {
| this.scope = scope;
| return;
| }
| }
|
| throw new IllegalArgumentException("ScopeType is not valid.");
| }
|
| @Column(name="scope", nullable=false)
| public int getScopeType() {
| return scope.getType();
| }
| }
|
So in my code i still use the enums but for storage i use the type value of the enum. If this bug is solved i only have to remove the added get/set method and remove the @Transient annotation.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3884826#3884826
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3884826
Ondřej Fafejta KYBERIE napsal(a):
|
- Re: EJB3, JBOSS - mapovaní výčtového typu enum Martin Bednář
- Re: EJB3, JBOSS - mapovaní výčtového typu enum Filip Jirsák
- Re: EJB3, JBOSS - mapovaní výčtovéh o typu enum Ondra Nekola
