简体   繁体   中英

Save Object in MYSQL database using Hibernate

I want to save a Properties object in mysql database. This is my code for the class.

@Entity
@Table(name = "tblexample")
public class Example
{
    @Column
    private Properties properties;

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

    //Getters and Setters
}

I was using columnDefinition = "OTHER" when using H2 db. But such option is not provided in MySql. So I wanted to know how does hibernate store my properties object in mysql. Does it store it as a TEXT/MEDIUMTEXT ? And when i retrieve the value from the database, do i have to convert the value from String to Properties?

Why you dont put @JoinColumn anatation on the application field.

I think firstly you should put @JoinColumn anatation and @manytoone/onetoone/onetomany anatation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM