OpenJPA handles a field using oneToMany Mapping as a Blob

I have a serious problem with implementing OneToMany JPA relationships, and I'm looking for a reasonable solution. The problem is that the JPA seems to get confused by reading its @OneToMany annotation and returning:

"Flea.dog" declares a column that is incompatible with the expected type "blob".

Flea.dog is a number field. The problem seems to be a known bug: https://issues.apache.org/jira/browse/OPENJPA-1481

The problem is created as follows: I have two Dog and Flea objects, the dog has many fleas represented by dog_id in the flea table. These objects are mapped to tables with different names. The dog is matched with Madra, Flea is matched with feithidi.

The tables are as follows:

CREATE TABLE madra (dogid BIGINT, name varchar(255), PRIMARY KEY (dogid)); CREATE TABLE feithidi (fleaid BIGINT, dogid BIGINT, PRIMARY KEY (fleaid)); 

I use H2 as an example, although I had the same problem with Oracle.

The objects are as follows:

 @Entity(name="feithidi") Flea{ @Id long fleaid; @ManyToOne @JoinColumn(name="dogid", insertable=false, updatable=false, nullable=true) private Dog dog; } 

and

 @Entity(name="madra") Dog{ @Id long dogid; String name; @OneToMany(mappedBy="dog") private Set<Flea> fleas; } 

I get the complete exception:

(org.apache.openjpa.persistence.ArgumentException: "Flea.dog" declares a column that is incompatible with the expected type "blob".

If someone has a job or I see a clear mistake on my part, I would be grateful for some feedback.

+4
source share
1 answer

I got the same error message because I forgot to put the Dog object in the persistence.xml file.

+5
source

Source: https://habr.com/ru/post/1345722/


All Articles