Pergunta

I have some trouble with creating an object in an entity class. I get following exception:

java.lang.IllegalArgumentException: A: name.A is not a supported property type

Here is a small code example:

This is my entity B class:

@Entity
public class B {        
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Key key;

    private ArrayList<A> token = new ArrayList<A>();

    public Profile() {
        this.token.add(new Token(1));
        this.token.add(new Token(2));
        this.token.add(new Token(3));
        this.token.add(new Token(4));
    }
}

This is my standard A class:

public class A {
    private Integer id = new Integer(0);

    public A(int id) {
        this.id = id;
    }
}

I save the class B in the datastore. I get the exception at following point:

profile = new Profile();
em.persist(profile);
em.close(); //Exception

If I comment the token object in class B everything is working. How could I use the class A in B?

Foi útil?

Solução

I believe the issue is that class A is not being identified as an entity to be managed. Can you use the following annotation at the top of Class A and see.

@Embeddable
public class A
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top