h2

Spring boot with H2 Database auto create

假装没事ソ 提交于 2021-02-10 12:43:03
问题 I am using embeded H2 in my java application via spring boot. Currently, it creates(overrides) my tables in the DB. But once I push it to production I do not want my tables to be wiped off and recreated, so I wont lose the previous datas in the tables. But I am not sure how to accomplish this. Not sure what to put on the line spring.jpa.hibernate.ddl-auto=create . I tried validate and other options but did not work out. Here is my application.properties. Thanks spring.jpa.generate-ddl=true

Spring boot with H2 Database auto create

余生颓废 提交于 2021-02-10 12:42:35
问题 I am using embeded H2 in my java application via spring boot. Currently, it creates(overrides) my tables in the DB. But once I push it to production I do not want my tables to be wiped off and recreated, so I wont lose the previous datas in the tables. But I am not sure how to accomplish this. Not sure what to put on the line spring.jpa.hibernate.ddl-auto=create . I tried validate and other options but did not work out. Here is my application.properties. Thanks spring.jpa.generate-ddl=true

h2 localhost url different from testdb

♀尐吖头ヾ 提交于 2021-02-08 09:52:51
问题 I am using below spring boot config: <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.3.1.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter

Hibernate @ManyToOne @JoinColumn is always null

非 Y 不嫁゛ 提交于 2021-02-08 04:12:11
问题 I'm trying to implement One-to-Many relation between two tables using hibernate. Here is my code: @Entity public class Board { @Id @Column(name = "board_id") @GeneratedValue private long id; @Column private String owner; @Column private String title; @Column private String refresh; @Column private Timestamp createDate; @Column private Timestamp modifyDate; @OneToMany(mappedBy="board", cascade=CascadeType.ALL) private List<Item> items; public long getId() { return id; } public void setId(long

Hibernate @ManyToOne @JoinColumn is always null

自古美人都是妖i 提交于 2021-02-08 04:09:18
问题 I'm trying to implement One-to-Many relation between two tables using hibernate. Here is my code: @Entity public class Board { @Id @Column(name = "board_id") @GeneratedValue private long id; @Column private String owner; @Column private String title; @Column private String refresh; @Column private Timestamp createDate; @Column private Timestamp modifyDate; @OneToMany(mappedBy="board", cascade=CascadeType.ALL) private List<Item> items; public long getId() { return id; } public void setId(long

H2 User defined aggregate function, ListAgg, can't use DISTINCT or TRIM() on the first parameter

不打扰是莪最后的温柔 提交于 2021-02-07 20:38:00
问题 So I have a DB2 production database in which I need to use the available function ListAgg. I would like my unit test, which is using H2, to correctly test this functionality. Unfortunately H2 does not support ListAgg directly. I can, however, create a user defined aggregate function... import java.sql.Connection; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import org.h2.api.AggregateFunction; import com.google.common.base.Joiner; public class ListAgg

H2 User defined aggregate function, ListAgg, can't use DISTINCT or TRIM() on the first parameter

戏子无情 提交于 2021-02-07 20:35:53
问题 So I have a DB2 production database in which I need to use the available function ListAgg. I would like my unit test, which is using H2, to correctly test this functionality. Unfortunately H2 does not support ListAgg directly. I can, however, create a user defined aggregate function... import java.sql.Connection; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import org.h2.api.AggregateFunction; import com.google.common.base.Joiner; public class ListAgg

H2 console and Spring Security - permitAll() not working

旧城冷巷雨未停 提交于 2021-02-07 14:56:52
问题 I'm creating rest api and implemented Spring Security - everything works fine but I want (for now, when I'm still developing) to be able for anyone without authorization to open localhost:8080/console. My code: @Override protected void configure(HttpSecurity http) throws Exception { // allow everyone to register an account; /console is just for testing http.authorizeRequests().antMatchers("/register", "/console").permitAll(); http.authorizeRequests().anyRequest().fullyAuthenticated(); //

Set port number for the embedded h2 database

≡放荡痞女 提交于 2021-02-07 12:29:18
问题 I use h2 in-memory database only for the testing purposes. The default port seems to be 8082 , which causes my tests to fail on heroku. I want to change this port number. How can I do that ? What I've done so far: There seems to be a file on my local machine ( $USER_HOME/.h2.server.properties ) that specifies this port. Let alone it is very strange to have that file outside of the application workspace, I cannot check it in heroku. I tried to set webPort , port in application-test.properties

Set port number for the embedded h2 database

狂风中的少年 提交于 2021-02-07 12:29:05
问题 I use h2 in-memory database only for the testing purposes. The default port seems to be 8082 , which causes my tests to fail on heroku. I want to change this port number. How can I do that ? What I've done so far: There seems to be a file on my local machine ( $USER_HOME/.h2.server.properties ) that specifies this port. Let alone it is very strange to have that file outside of the application workspace, I cannot check it in heroku. I tried to set webPort , port in application-test.properties