hibernate-annotations

Custom @Column JPA Annotations, how to?

左心房为你撑大大i 提交于 2021-02-08 03:47:32
问题 Been trying hard to search for a solution to create some Custom JPA Annotations to replace repetitive fields when declaring Entity POJOs. Any help? Here what I am trying to achieve: //@Column(name = "is_enabled", nullable = false, columnDefinition = "tinyint(1) DEFAULT 1") @ColumnBooleanNotNullDefaultOne private Boolean isEnabled; or //@Column(name = "created", nullable = false, updatable = false, insertable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") @ColumnTimestamp

Why changing the order of the joinColumn, hibernate return a correct or incorrect query?

北城余情 提交于 2020-01-24 10:51:06
问题 PROBLEM: Why changing the order of the joinColumn, hibernate return a correct or incorrect query? FIRST JOIN: @OneToOne @JoinTable(name="TTR_POA_UPA", joinColumns = { @JoinColumn(name="ANO", insertable=false, updatable=false), @JoinColumn(name="ID_ESCALA", insertable=false, updatable=false), @JoinColumn(name="MES", insertable=false, updatable=false) }, inverseJoinColumns = { @JoinColumn(name="ANO", insertable=false, updatable=false), @JoinColumn(name="ID_ESCALA", insertable=false, updatable

Problem with 2 levels of inheritance in hibernate mapping

北城余情 提交于 2020-01-24 05:35:07
问题 Here's my class structure: class A class B extends A class C extends A class D extends C class E extends C And here are my mappings (class bodies omitted for brevity): Class A: @Entity @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @MappedSuperclass @DiscriminatorColumn( name="className", discriminatorType=DiscriminatorType.STRING ) @ForceDiscriminator public abstract class A Class B: @Entity @DiscriminatorValue("B") public class B extends A Class C: @Entity @DiscriminatorValue("C")

Java Hibernate Mapping Exception! (Could not determine type for: java.util.Map)

不问归期 提交于 2020-01-11 08:49:47
问题 I have made a class with name of Movie with folowing fields: @Id @GeneratedValue private Long id; private String name; @ElementCollection(targetClass = String.class) private Map<String, String> properties; private Double rate; private Integer votersCount; private Date releaseDate; private Integer runtime; @ManyToMany @JoinTable(name = "movie_director") @IndexColumn(name = "directorIndex") private List<Person> directors; @ManyToMany @JoinTable(name = "movie_writer") @IndexColumn(name =

Creating Indexes on DB with Hibernate @Index Annotation

陌路散爱 提交于 2020-01-10 12:04:13
问题 I have annotation-driven hibernate capabilies on my project. Now I want to create an index over a column. My current column definition is @NotNull @Column(name = "hash") private String hash; and I add @Index annotation here. @NotNull @Column(name = "hash") @Index(name="hashIndex") private String hash; and then DROP TABLE and restart Tomcat server. After the server is instantiated, the table is created but I can't see new index on following query. SHOW INDEX FROM tableName It is expected to

Hibernate error - org.hibernate.MappingException: Unknown entity:

柔情痞子 提交于 2020-01-06 21:14:43
问题 guys ! i have very strange problem with hibernate 5. I receive Exception in thread "main" org.hibernate.MappingException: Unknown entity: com.rosko.Merchandiser When i remove configuration.addAnnotatedClass(com.rosko.Merchandiser.class) HibernateUtil.java public class HibernateUtil { private static final SessionFactory sessionFactory = buildSessionFactory(); private static SessionFactory buildSessionFactory() { try { Configuration configuration = new Configuration(); configuration.configure()