2

I want to use spring boot data JPA with MySql 8 collections.

MySql8 has already provided with XDevApi but I want to configure it with Spring boot data JPA.

Mysql XDevApi given in below link https://dev.mysql.com/doc/x-devapi-userguide/en/devapi-users-working-with-collections.html

Is it possible with spring boot data JPA?

1 Answers1

0

Maybe it's to late but, yes you can do it.

It's very similar really, the change is made in the database port (msqlx uses the por 33060) and the connection string.

In the spring properties file you should write this lines

database.path=mysqlx://localhost:33060/world_x?user=username&password=yourpass
database.schema=world_x

wordl_x is the default schema, you can create your own and change it.

The connection can be made with something like this

@Configuration
public class MySQLConnection {

@Value("${database.path}")
private String databaseUrl;

@Value("${database.schema}")
private String databaseSchema;

@Bean
public Session getSession() {
    return new SessionFactory().getSession(databaseUrl);
    
}

@Bean
public Schema getSchema() {
    return getSession().getSchema(databaseSchema);
}
}

Remenber that you must to handle collections instead tables.

Rosendo Ropher
  • 496
  • 8
  • 21