Everything was working fine when we were using JDK 11 and Spring Boot 2.4 but we have upgraded from: Spring boot 2.4 to 3.1.2 java 11 to java 20 and few more upgrades We are also using mapstructs in project.
Getting Error when I am trying to fetch the data of Invities from AccountsEntity in the below code. Invities Entity has One to Many kind of relationship with Accounts.
Set<AccountsEntity> accountsEntitiesForAdmin = accountsRepo.findAllByAccountOwnerAndIsActiveTrue(requestingUser)
.orElse(null);
AccountsEntity
@Entity
@Table(name = "tbl_account")
@Where(clause = "is_deleted = false")
public class AccountsEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue (strategy = GenerationType.IDENTITY)
@Column(name = "tbl_account_id_pk")
private Long accountId;
@Column(name = "account_name")
private String accountName;
@Enumerated(EnumType.STRING)
@Column(name = "account_type")
private AccountType accountType;
@Column(name = "account_image")
private String accountImage;
@OneToOne
@JoinColumn(name = "tbl_app_user_creator_id_fk", referencedColumnName = "tbl_app_user_id_pk")
private RegisteredProfileEntity appUserCreator;
@OneToOne
@JoinColumn(name = "tbl_app_user_owner_id_fk", referencedColumnName = "tbl_app_user_id_pk")
private RegisteredProfileEntity accountOwner;
@Column(name = "creation_date_time", columnDefinition = "TIMESTAMP", nullable = false)
@CreatedDate
private ZonedDateTime creationDateTime;
@Column(name = "last_modified_date_time", columnDefinition = "TIMESTAMP", nullable = false)
@LastModifiedDate
private ZonedDateTime updationDateTime;
@Column(name = "is_active")
private boolean isActive;
@Column(name = "created_by")
private Long createdBy;
@Column(name = "updated_by")
private Long updatedBy;
@Column(name = "is_deleted")
private boolean isDeleted;
@OneToMany(mappedBy = "account")
private List<MembersEntity> appMembers;
@OneToMany(mappedBy = "account")
private Set<InvitationEntity> invities;
@OneToMany(mappedBy = "accounts")
private Set<TwilioUnassignedNumberEntity> twilioUnassignedNumbers;
@Column(name = "version")
@Version
private Long version;
InvitationEntity
@Entity
@Table(name = "tbl_invitation_app_and_nonapp")
@Where(clause = "is_deleted = false")
public class InvitationEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue (strategy = GenerationType.IDENTITY)
@Column(name = "tbl_invitation_id_pk")
private Long invitationId;
@Column(name = "status")
private StatusTypeEnum statusTypeEnum;
@Enumerated(EnumType.STRING)
@Column(name = "module_type")
private ModuleType moduleType;
@Column(name = "sms")
private String sms;
@ManyToOne
@JoinColumn(name = "tbl_account_id_fk")
private AccountsEntity account;
@ManyToOne
@JoinColumn(name = "tbl_conference_id_fk")
private ConferenceEntity conference;
@ManyToOne
@JoinColumn(name = "tbl_group_id_fk")
private GroupEntity group;
@ManyToOne
@JoinColumn(name = "tbl_twilio_phone_number_id_fk")
private TwilioPhoneNumberEntity twilioPhoneNumberEntity;
@Enumerated(EnumType.STRING)
@Column(name = "twilio_phone_number_type")
private TwilioPhoneNumberType twilioPhoneNumberType;
@ManyToOne
@JoinColumn(name = "tbl_app_user_sender_fk")
private RegisteredProfileEntity sender;
@ManyToOne
@JoinColumn(name = "tbl_app_user_reciever_fk")
private RegisteredProfileEntity reciever;
@ManyToOne
@JoinColumn(name = "tbl_non_app_user_id_fk")
private NonAppUserEntity nonAppUser;
@Column(name = "creation_date_time", columnDefinition = "TIMESTAMP", nullable = false)
private ZonedDateTime creationDateTime;
@Column(name = "last_modified_date_time", columnDefinition = "TIMESTAMP", nullable = false)
private ZonedDateTime updationDateTime;
@Column(name = "is_active")
private boolean isActive;
@Column(name = "created_by")
private Long createdBy;
@Column(name = "updated_by")
private Long updatedBy;
@Column(name = "is_deleted")
private boolean isDeleted;
@Column(name = "twilio_sender_reciept")
private String twilioSenderReciept;
@Column(name = "reinvite_count")
private int reInviteCount;
in application.proerties made these two entries run with latest upgrades for testing.
spring.main.allow-circular-references=true spring.jpa.open-in-view=true
we are expecting that
Set<AccountsEntity> accountsEntitiesForAdmin = accountsRepo.findAllByAccountOwnerAndIsActiveTrue(requestingUser)
.orElse(null);
this should give the result but its giving us the error.
Unable to evaluate the expression Method threw 'java.lang.ArrayIndexOutOfBoundsException' exception.
Index 50 out of bounds for length 4
DB Query result image:
Postman hit:



I got the solution but donot why it is not working with upgrade as you can see I have used a enum in the invitation entity which is directly used
StatusTypeEnum without enumerated as string is not working in my case but after placing the same it worked.
Any thought on this community