h2

HIBERNATE - JPA2 - H2 - Querying @ElementCollections HashMap by key

走远了吗. 提交于 2019-12-18 17:43:33
问题 I'm using hibernate-entitymanager 3.6.4.Final and h2 database 1.3.155 I'm using the H2Dialect. I'm having trouble filtering records by elements in an @ElementCollection. Here is my entity @Entity public class Item { @Id @GeneratedValue(strategy = GenerationType.AUTO) @MapKeyColumn(name="name", length=50) @Column(name="value", length=100) protected Map<String, String> attributes; /* etc. */ } Here is my query : Item item = em.createQuery("FROM Item i JOIN i.attributes a WHERE KEY(a)=

H2 database In memory - Init schema via Spring/Hibernate

社会主义新天地 提交于 2019-12-18 17:34:11
问题 I have a Spring/Hibernate application with H2 database and I have a few issues with configuring H2 to run in an embedded mode (in memory): 1. I want spring to start the H2 database so I created the following Spring beans: <bean id="org.h2.tools.Server" class="org.h2.tools.Server" factory-method="createTcpServer" init-method="start" destroy-method="stop"> <constructor-arg value="-tcp,-tcpAllowOthers,true,-tcpPort,8043" /> </bean> <bean id="org.h2.tools.Server-WebServer" class="org.h2.tools

SpringBoot Accessing H2 console

冷暖自知 提交于 2019-12-18 17:14:24
问题 I have a basic SpringBoot app., embedded Tomcat, Thymeleaf template engine. I've created this bean to access the console: @Bean public ServletRegistrationBean h2ConsoleServletRegistration() { ServletRegistrationBean bean = new ServletRegistrationBean(new WebServlet()); bean.addUrlMappings("/console/*"); return bean; } but when I access to the console http://localhost:8080/appContext/console/login.do?jsessionid=f3585792a9bf1f0cf1a0b6a09dcefe1a I have my beans annotated as follows: @Entity

Grails throws Table “xxx” not found

泪湿孤枕 提交于 2019-12-18 09:14:08
问题 In Grails I can create domain objects to a H2 in memory dataSource in BootStrap and get results back ok, but once the app is up (eg query from GSP or controller) and I try to run a query I get this: org.h2.jdbc.JdbcSQLException: Table "FUNCTIONAL_DOC_TYPE" not found; SQL statement: select this_.id as id1_0_, this_.version as version1_0_, this_.direction_id as direction3_1_0_, this_.functional_group_id as functional4_1_0_, this_.type_name as type5_1_0_ from functional_doc_type this_ [42102-147

Grails accessing H2 TCP server hangs

女生的网名这么多〃 提交于 2019-12-18 07:43:21
问题 I have a Grails app which works fine when using the default embedded H2 database. Now I'd need to run some tests where I need more integrated environment, so I thought of using H2 in server mode for this and making my other apps access the same DB. I start the H2 server from command line and get tcp://192.168.56.1:9092 for the server URL. I've set it in Grails datasource as jdbc:h2:tcp://localhost:9092/~/devDb;IFEXISTS=TRUE . Once I start the Grails app, it simply hangs. The log file is empty

MyBatis how can I generate different sql for different database backend

倾然丶 夕夏残阳落幕 提交于 2019-12-18 04:17:21
问题 I'm using mybatis-spring 1.2.3 together with Spring4 to create a web application. The main data storage is MySQL in production environment, but I also use in-memory database H2 in unit testing. MyBatis works well with both of MySQL and H2 in testing and production, but I come across a problem that one day I need to use force index(idx1) in a query to MySQL, which will cause a syntax error in unit testing as H2 hasn't supported force index . As the result, the unit testing is totally broken. I

Schema related problems with Flyway / Spring and H2 embedded database

六眼飞鱼酱① 提交于 2019-12-18 02:49:57
问题 I am building a Spring 3 MVC app that uses a MySQL database and have recently integrated Flyway into the solution to manage the database migrations. I have successfully configured my applicationContext.xml according to the Flyway documentation such that, upon application startup, Flyway will migrate to the latest version. I am having trouble getting Flyway to play nicely with my unit / functional tests. I am using Spring Data JPA for my data access layer and have built some JUnit tests to

Does Spring embedded database support different SQL dialects?

倾然丶 夕夏残阳落幕 提交于 2019-12-18 02:42:06
问题 H2 has a range of compatibility modes for various other databases such as MS SQL Server, MySQL, Oracle, etc that support different SQL dialects. However, when setting up an embedded database in Spring I do not find any corresponding setting. Does this imply that I have to use "plain" SQL without any dialect specific features if I for example use Oracle in production and H2 during test? Have I overlooked something? 回答1: According to the H2 doc, the Oracle compatibility mode is quite limited.

problem with INIT=RUNSCRIPT and relative paths

混江龙づ霸主 提交于 2019-12-17 22:23:22
问题 I use maven conventions for source paths (src/main src/test) and i have my sql scripts in src/main/resources/scripts. I want to run my app with H2 memory and i'd like to use the jdbc url to initialize my db : database.url=jdbc:h2:mem:;INIT=RUNSCRIPT FROM 'src/main/resources/scripts/create.sql'; My problem is that this relative path (src/main/... ) does not work, and that H2 won't crash if the init=runscript command targets nothing. Does someone know what is the path i should use to make this

Connect to H2 database using IntelliJ database client

人盡茶涼 提交于 2019-12-17 22:15:46
问题 My Grails app uses a h2 database in dev mode (the default behaviour for Grails apps). The DB connection settings in DataSource.groovy are dataSource { pooled = true jmxExport = true driverClassName = "org.h2.Driver" username = "sa" password = "" dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', '' url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE" } I'm trying to setup a connection for this database using IntelliJ IDEA's database