Typedef Repository not working in SpringBoot JPA

33 Views Asked by At

in my SpringBoot application I have a table to store json values, but it is not working. The code is stopping at the repository call and also not showing any exception. SpringBoot version used is 2.7.6. On debugging found that repository is created but not progressing.


<dependency>
    <groupId>com.vladmihalcea</groupId>
    <artifactId>hibernate-types-52</artifactId>
    <version>2.21.1</version>
</dependency>


@Entity
@Table(name = "ORDERSJSONB")
@Data
@AllArgsConstructor
@NoArgsConstructor
@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
public class OrderInputEntity {

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Column(name = "id")
    private Integer id;

    @Column(name = "order_id")
    private String orderId;

    @Column(name = "country")
    private String country;

    @Column(name = "customer_type")
    private String customerType;

    @Column(name = "status")
    private Integer status;

    @Column(name = "order_items")
    @Type(type = "jsonb")
    private List<OrderItem> orderItems;
}


@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode
public class OrderItem implements Serializable {

    private BigDecimal cabinet;
    private BigDecimal sofa;
    private BigDecimal chairs;
    private BigDecimal tables;
}



//insert in database
            orderInputRepository.deleteAll();
            AtomicInteger x = new AtomicInteger(1);
            orderInputMap.forEach((fileName, orderInput) -> {
                    OrderInputEntity orderInputEntity = new OrderInputEntity();
                    orderInputEntity.setId(x.get());
                    orderInputEntity.setOrderId(orderInput.getOrderId());
                    orderInputEntity.setCountry(orderInput.getCountry());
                    orderInputEntity.setCustomerType(orderInput.getCustomerType());
                    orderInputEntity.setStatus(orderInput.getStatus());
                    orderInputEntity.setOrderItems(orderInput.getOrderItems());
                    orderInputRepository.save(orderInputEntity);
                    x.getAndIncrement();

            });
            System.out.println("JSON files inserted in Database...");


0

There are 0 best solutions below