Hi,
I am using Java 21, Hibernate 7.0.6.Final and spring-boot-starter-data-jpa 3.5.3.
As a general info:
The explained structure is defined by an old application which cannot be changed.
In the past the stored procedures using this structure were called from Java using oracle.sql.STRUCT and oracle.sql.ARRAY. We are now trying to add some features but have to use the existing complex stored procedure but using Java 21.
Description:
We have a custom Oracle Data Type OT_COUNTRY, which contains a list of partners.
This list of partners is wrapped with another custom Oracle Datatype TT_PARTNERS and this type contains a list of
OT_PARTNER.
create or replace TYPE "OT_COUNTRY" AS object (
COUNTRY_CODE VARCHAR2(2),
COUNTRY_NAME VARCHAR2(2000),
AMOUNT NUMBER,
PARTNERS TT_PARTNERS
);
create or replace TYPE "OT_PARTNER" as object (
code NVARCHAR2(20),
name NVARCHAR2(200),
phone_number NVARCHAR2(200)
);
create or replace TYPE "TT_PARTNERS" as TABLE OF OT_PARTNER;
The Java classes are all defined as @Embeddable and used inside the other class as @Embedded.
@Embeddable
....
@Struct(name = "OT_COUNTRY", attributes = { "countryCode", "countryName", "amount", "partners" })
public class OTCountry implements Serializable {
private static final long serialVersionUID = -6577203874286836224L;
private String countryCode;
private String countryName;
private Long amount;
@Embedded
private TTPartner partners;
}
@Embeddable
...
@Struct(name = "TT_PARTNER", attributes = { "listOfPartners" })
public class TTPartner implements Serializable {
private static final long serialVersionUID = -6155092651111036183L;
@Embedded
@ElementCollection(targetClass = OTPartner.class)
private List<OTPartner> listOfPartners;
}
@Embeddable
...
@Struct(name = "OT_PARTNER", attributes = { "code", "name", "phoneNumber" })
public class OTPartner implements Serializable {
private static final long serialVersionUID = -6577203874286836224L;
private String code;
private String name;
private String phoneNumber;
}
The class OTCountry is added to a dummy Hibernate Entity class to let Hibernate create the metadata for these @Embeddables.
This structure is needed for calling some of the existing complex Oracle stored procedures.
When trying to deploy the war-File I always receive the following exception:
org.hibernate.AssertionFailure: Collection property holder does not have a class name
This message comes directly from org.hibernate.boot.model.internal method.CollectionPropertyHolder.getClassName()
@Override
public String getClassName() {
throw new AssertionFailure( "Collection property holder does not have a class name" );
}
Is this structure not supported by Hibernate? Does it mean I have to continue working directly with JPA?
Or am I doing something wrong? Is there another way?