Код: Выделить всё
@Entity
@Table(name = "price_project")
class PriceProject(
@Column val priceEur: Double,
@Column(name = "valid_from", columnDefinition = "TIMESTAMP WITH TIME ZONE")
val validFrom: ZonedDateTime?,
@Enumerated(EnumType.STRING)
@Column val projectType: ProjectTypes
) {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
var id: Long = 0
}
Код: Выделить всё
@EnumNaming(EnumNamingStrategies.CamelCaseStrategy::class)
enum class ProjectTypes {
national,
international,
trans_national,
global,
}
Код: Выделить всё
CREATE TABLE public.price_project (
id bigint NOT NULL,
price double precision,
project_type public.project_types NOT NULL,
valid_from timestamp with time zone NOT NULL,
);
CREATE TYPE public.project_types AS ENUM (
'national',
'international',
'trans_national',
'global',
);
Код: Выделить всё
interface ProjectPriceRepository : JpaRepository
{
@Query("""
SELECT p FROM PriceProject p
WHERE p.validFrom
Подробнее здесь: [url]https://stackoverflow.com/questions/78400747/why-doesnt-jpa-query-cast-enum-automatically[/url]