h2

JpaRepository findAll() returns empty result

狂风中的少年 提交于 2019-12-10 17:01:29
问题 JpaRepository findAll() method returns empty result. I am trying to implement rest service by using Spring-boot, h2 database and jpa. Here is my schema.sql CREATE TABLE IF NOT EXISTS `City` ( `city_id` bigint(20) NOT NULL auto_increment, `city_name` varchar(200) NOT NULL, PRIMARY KEY (`city_id`)); My data.sql file includes : INSERT INTO City (city_id,city_name) VALUES(1,'EDE'); INSERT INTO City (city_id,city_name) VALUES(2,'DRUTEN'); INSERT INTO City (city_id,city_name) VALUES(3,'DELFT'); The

H2 console access for databases other than h2

与世无争的帅哥 提交于 2019-12-10 15:41:36
问题 H2 console (http://localhost:8082/login.jsp) has the option to look at details of any database, where should we copy the jdbc driver if we have tp talk to the mysql or other database servers. Copying the jdbc driver file (mysql-connector-java-5.0.8-bin.jar) under bin directory didn't seem to help Note: My H2 server is running as a service 回答1: To use other databases (for example MySQL), the location of the JDBC drivers of those databases need to be added to the environment variables H2DRIVERS

Finding all entries where a collection field contains any of the given items

限于喜欢 提交于 2019-12-10 15:30:11
问题 I have a Spring Boot application that contains an entity like this (some fields stripped for compactness): @Entity public class Message extends AbstractPersistable<Long> { @ManyToMany(targetEntity = Tag.class, fetch = FetchType.EAGER) private Set<Tag> tags; // getter and setter for tags here } Tag is just a simple entity with a name field. Now, I have another Set<Tag> in my code obtained from the user. I want to find all Message s that have any of the tags in this set. For example, if we have

spring hibernate .. H2 database - schema not found

二次信任 提交于 2019-12-10 14:21:07
问题 I am trying to persist some data into the H2 database. but I keep getting the schema not found error message as below. Jan 02, 2014 8:55:51 PM org.apache.catalina.core.AprLifecycleListener init INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.7.0_45\bin;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;M:\app\oracleuser\product\12.1.0\dbhome_1\bin;C:\Program

org.h2.jdbc.JdbcSQLException: Column “ID” not found

心已入冬 提交于 2019-12-10 14:20:25
问题 I have the following DDL in my code: CREATE TABLE IF NOT EXISTS SOMETABLE ( id BIGINT AUTO_INCREMENT NOT NULL, ... FOREIGN KEY (id) REFERENCES OTHERTABLE(id) ... ); Here's the definition of OTHERTABLE: create table "OTHERTABLE" ( "id" BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) NOT NULL PRIMARY KEY, "code" VARCHAR NOT NULL, "name" VARCHAR NOT NULL, "enabled" BOOLEAN NOT NULL, "app_id" VARCHAR NOT NULL); Please note that OTHERTABLE is auto generated by SLICK (Scala ORM Stack)! This

Year changing from negative -509 to a positive 510 in JDBC with H2 Database

走远了吗. 提交于 2019-12-10 13:14:45
问题 -509 vs 510 I am seeing some kind of altered or erroneous data, with the use of JDBC. So I observe using H2 Database version 1.4.196 on Java 8 Update 151. Here is a complete example. Note how we retrieve the date value three times, first as a LocalDate object, secondly as text, and thirdly as an int year number extracted from a cast LocalDate object. In the text version we can see that the year is indeed negative. Mysteriously the LocalDate has a different year number and it is positive

hibernate h2 embeddable list expected “identifier”

纵饮孤独 提交于 2019-12-10 13:14:20
问题 I'm trying to associate a list of function (whom Embeddable) within my Employee Entity and H2 seems unhappy with this saying that it expected an "identifier" Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement " CREATE TABLE EMPLOYEE_FUNCTIONS ( EMPLOYEE_EMPLOYEEID VARCHAR(255) NOT NULL, ACTIVE BOOLEAN NOT NULL, DEPARTMENTNUMBER INTEGER NOT NULL, DESCRIPTION VARCHAR(255), ORDER[*] INTEGER NOT NULL ) "; expected "identifier"; The thing is I already done that with an other

Long string data type in H2 databases

别说谁变了你拦得住时间么 提交于 2019-12-10 12:39:16
问题 I am trying to create an H2 database to manage some text clippings. One of the fields will contain a large string that may be hundreds and, in a few instances, thousands of words long. Ideally I would not want to limit the size of this field at the moment when the table is created; it'd be best for this to be dynamically sized, but if that is not possible would want to allocate generously so that the text is not cut. Any suggestions on how to implment this? Is VARCHAR(10,000) possible? crazy?

Insert Java byte[] object into an H2 table and then retrieve it again

给你一囗甜甜゛ 提交于 2019-12-10 10:42:54
问题 I'm trying to insert a Java byte[] into an H2 database table and then retrieve it again, but i am not achieving success. According to this page, the BINARY data type maps directly to a byte[]. So my understanding is i can write the byte[] variable directly to the column, but it is resulting in an exception when i try to retrieve it again. Here is a SSCCE that illustrates my problem. What am i doing wrong here? PS: You need to have an H2 database installed to run this code. package coza.modh

H2 database and functions in separate schemas

风流意气都作罢 提交于 2019-12-10 10:19:14
问题 I'm trying to create a test database (with H2 database). I'm using Oracle in production, and it seems nice to have oracle compatibility mode in h2. However I've got a problem with translating oracle construction: create or replace PACKAGE permission_tools IS FUNCTION get_role_access_level( p_role_id IN NUMBER, p_permiss IN VARCHAR2) RETURN NUMBER; END permission_tools; which I'm calling with: select permission_tools.get_access_level(?, ?) from dual; into H2 equivalent. I've been trying