Liquibase i adnotacje Hibernate

0

Hey, mam pytanie czy używając Liquibase do tworzenia tabel powinienem używać dodatkowo adnotacji takich jak np:
@ManyToOne
@Enumerated(EnumType.STRING) itp czy wystarczy @Entity i @Id a resztę ustawiam w pliku liquibase poniżej przykład:

@AllArgsConstructor
@Builder
@Getter
@Setter
@Entity
public class Product {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @ManyToOne
    private Employee foundryEmployee;

    @Enumerated(EnumType.STRING)
    private ProductType type;

    private LocalDateTime foundryDate;
}
<databaseChangeLog
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.7"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.7
         http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.7.xsd">

    <changeSet id="5" author="Konrad">
        <createTable tableName="Products">
            <column name="id" type="bigint" autoIncrement="true">
                <constraints primaryKey="true" nullable="false" unique="true"/>
            </column>
            <column name="foundryEmployee" type="bigint">
                <constraints nullable="false" foreignKeyName="fk_employee" references="employees(id)" unique="false"/>
            </column>
            <column name="type" type="varchar(30)">
                <constraints nullable="false" primaryKey="false" unique="false"/>
            </column>
            <column name="foundryDate" type="timestamp">
                <constraints nullable="false" primaryKey="false" unique="false"/>
            </column>
        </createTable>
    </changeSet>
</databaseChangeLog>

a tak przy okazji to mi niestety jeszcze nie działa poniewaz dostaje, może wiecie o co chodzi z tym mapowaniem.:

Caused by: org.hibernate.MappingException: Could not determine type for: models.Employee, at table: Product, for columns: [org.hibernate.mapping.Column(foundryEmployee)]
	at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:488) ~[hibernate-core-5.4.7.Final.jar:5.4.7.Final]
	at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:455) ~[hibernate-core-5.4.7.Final.jar:5.4.7.Final]
	at org.hibernate.mapping.Property.isValid(Property.java:227) ~[hibernate-core-5.4.7.Final.jar:5.4.7.Final]
	at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:624) ~[hibernate-core-5.4.7.Final.jar:5.4.7.Final]
	at org.hibernate.mapping.RootClass.validate(RootClass.java:267) ~[hibernate-core-5.4.7.Final.jar:5.4.7.Final]
	at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:343) ~[hibernate-core-5.4.7.Final.jar:5.4.7.Final]
	at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:461) ~[hibernate-core-5.4.7.Final.jar:5.4.7.Final]
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:708) ~[hibernate-core-5.4.7.Final.jar:5.4.7.Final]
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724) ~[hibernate-core-5.4.7.Final.jar:5.4.7.Final]
	at org.springframework.orm.hibernate5.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:615) ~[spring-orm-5.1.2.RELEASE.jar:5.1.2.RELEASE]
	at org.springframework.orm.hibernate5.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:599) ~[spring-orm-5.1.2.RELEASE.jar:5.1.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1741) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE]
	... 114 common frames omitted
1

Mapowania muszą być tak czy inaczej, ponieważ służą do generowania poprawnych zapytań SQL.

2

To są dwa osobne zagadnienia. Liquibase może sobie generować tabele, ale Hibernate musi mieć informacje, jak te tabele są odwzorowane w klasach Java. Dlatego adnotacje są potrzebne. Swoją drogą zapewne uległeś zmyłce związanej z generowaniem bazy danych przez Hibernate.

1 użytkowników online, w tym zalogowanych: 0, gości: 1