JAVA + HIBERNATE

Asked

Viewed 84 times

1

I started using Hibernate and I am very lay in the subject, what I really want to know is: When we map a class for Hibernate to automatically create the table in the database, it is possible to control what will run in the database?

For example: If I change the name of an attribute or add an attribute to my class, can I disable the function of changing the database automatically? How can I have this kind of control?

2 answers

1


You can define some restrictions through the annotations of framework, one of them is the note @Transient that allows you to ignore the field mapping in the table.

0

First I advise you to take a look at this link that talks about DDL command execution strategies using Hibernate.

If you simply want to change the java attribute and you don’t want this change to change the column name in the database, you need to annotate your attribute with Annotation @Column

@Column(name = "TBG_MINHA_COLUNA")
private String myColumn;

To inhibit automatic mapping of the attribute by Hibernate, you should write it down with @Transient specifies that the attribute will not be persisted.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.