From 15121842f16d343da75c39eec12310b3665b4fa3 Mon Sep 17 00:00:00 2001 From: Fabio Massimo Ercoli Date: Tue, 7 Dec 2021 15:52:56 +0100 Subject: [PATCH] Test persist of array of dates --- .../orm/test/array/DateArrayTest.java | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/array/DateArrayTest.java diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/array/DateArrayTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/array/DateArrayTest.java new file mode 100644 index 0000000000..4247ce0d71 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/array/DateArrayTest.java @@ -0,0 +1,66 @@ +/* + * Hibernate Search, full-text search for your domain model + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.orm.test.array; + +import java.util.Date; + +import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; +import org.junit.Test; + +import jakarta.persistence.Column; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.OrderColumn; + +public class DateArrayTest extends BaseCoreFunctionalTestCase { + + @Override + protected Class[] getAnnotatedClasses() { + return new Class[] { DateArrayEntity.class }; + } + + @Test + public void run() throws InterruptedException { + inTransaction( session -> { + DateArrayEntity entity = new DateArrayEntity(); + entity.setDates( new Date[] { new Date() } ); + session.persist( entity ); + } ); + } + + @Entity(name = "DateArrayEntity") + public class DateArrayEntity { + + @Id + @GeneratedValue + private Long id; + + @ElementCollection + @OrderColumn + @Column(name = "dates_column") + private Date[] dates = new Date[0]; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Date[] getDates() { + return dates; + } + + public void setDates(Date[] dates) { + this.dates = dates; + } + } + +}