h2

Play framework 2.4.3 evolutions not triggered

血红的双手。 提交于 2019-12-07 16:55:26
问题 I'm doing the todo tutorial of Play. When I created the evolution in conf/evolutions/default/1.sql nothing happens. I just get the Exception JdbcSQLException: Table "TASK" not found which makes sense. I applied the evolution manually to the DB with h2-browser in activator console and after that it works. But the evolutions don't show up automatically. application.conf # Database configuration # ~~~~~ # You can declare as many datasources as you want. # By convention, the default datasource is

H2 database: slow query although index is used

淺唱寂寞╮ 提交于 2019-12-07 15:24:18
问题 Using the H2 1.3.176. 1) table definition: CREATE TABLE TEST(ID BIGINT PRIMARY KEY, ACCOUNT BIGINT, TXID BIGINT); 2) inserting values into the table: INSERT INTO TEST SELECT X, RAND()*100, X FROM SYSTEM_RANGE(1, 1000000) 3) creating an index to use for my query: CREATE Unique INDEX IDX_TEST_ACCOUNT_TXID ON `test` (account, txId DESC); 4) doing the following query: explain analyze select txid from test where account=22 AND txid<9999999 order by txid desc limit 25 I get the following execution

Play framework 2.0.1 keeps trying to evolve wrong database type

半城伤御伤魂 提交于 2019-12-07 12:19:20
问题 I'm working on play 2.0.1 application deployed on openshift DIY-application. I'm having troble with the database because play keeps trying to evolve the wrong database. I have a mysql database and play creates an H2 database evolution script. Here are the scripts. What he is trying to create create table gif ( id bigint not null, title varchar(255), add_date timestamp, gif_url varchar(255), img_source varchar(5000), web_id varchar(255), found_on varchar(255), thumbnail varchar(255), version

TO_CHAR function not available in H2 database

我怕爱的太早我们不能终老 提交于 2019-12-07 10:52:19
问题 I am using H2 database for integration test. The code is quiet old and is using JDBC queries instead. While running tests i am getting the error below org.h2.jdbc.JdbcSQLException: Function "TO_CHAR" not found; SQL statement: I can see that H2 does not implecitely supports TO_CHAR function. Is there any way to add a custom methor or should i think about moving to HSQL DB or any other database for testing purpose. 回答1: Use the newer version 1.3.175. Since 2014-01-18 available with a TO_CHAR

Browse Corda database tables using H2 web interface shows synonyms errors

房东的猫 提交于 2019-12-07 10:40:53
问题 I followed the instructions at this link to browse corda database. However, I am getting below errors when I queried for tables. Error: Table "SYNONYMS" not found; SQL statement: SELECT TABLE_CAT, TABLE_SCHEM, TABLE_NAME, TABLE_TYPE, REMARKS, TYPE_CAT, TYPE_SCHEM, TYPE_NAME, SELF_REFERENCING_COL_NAME, REF_GENERATION, SQL FROM (SELECT SYNONYM_CATALOG TABLE_CAT, SYNONYM_SCHEMA TABLE_SCHEM, SYNONYM_NAME as TABLE_NAME, TYPE_NAME AS TABLE_TYPE, REMARKS, TYPE_NAME TYPE_CAT, TYPE_NAME TYPE_SCHEM,

Conditional Unique index on h2 database

我们两清 提交于 2019-12-07 09:21:14
问题 I have a SAMPLE_TABLE with a column BIZ_ID which should be unique when the column active is not equal to 0. On an oracle database the index looks like this: CREATE UNIQUE INDEX ACTIVE_ONLY_IDX ON SAMPLE_TABLE (CASE "ACTIVE" WHEN 0 THEN NULL ELSE "BIZ_ID" END ); How would this unique index look like on a h2 database? 回答1: In H2, you could use a computed column that has a unique index: create table test( biz_id int, active int, biz_id_active int as (case active when 0 then null else biz_id end)

PARTITION BY doesn't work in H2 db

℡╲_俬逩灬. 提交于 2019-12-07 08:58:48
问题 I'm using PARTITION BY clause to do sorting on the result. Details for using PARTITION BY is mentioned in this question Sql Order by on multiple column. It works fine when i run in Oracle. I'm using H2 db for my unit test cases. When i run the same query on H2 db, it doesn't work. Is it known issue in H2? Is there any alternate solution which can work in Oracle and H2 both. 回答1: I don't think H2 supports window functions (aka analytic functions). However, you can do the query in the link

Installing and starting the H2 database on Ubuntu

自古美人都是妖i 提交于 2019-12-07 06:54:50
问题 I would like to use the H2 database on Ubuntu 12.10, and went to the website and got the platform independent install file. The installation instructions are quite literally, "To install the software, run the installer or unzip it to a directory of your choice." I'm not a Linux novice, so I've used many of the usual install procedures before, but I have no idea what I am supposed to do here. There are no configure or makefiles that I can find, and the documentation doesn't mention anything,

Play Framework: Error getting sequence nextval using H2 in-memory database

烂漫一生 提交于 2019-12-07 06:30:39
问题 As the title suggests, I get an error running Play 2.0.1 Tests using a FakeApplication w/ H2 in memory. I set up a basic unit test: public class ModelTest { @Test public void checkThatIndustriesExist() { running(fakeApplication(inMemoryDatabase()), new Runnable() { public void run() { Industry industry = new Industry(); industry.name = "Some name"; industry.shortname = "some-name"; industry.save(); assertThat(Industry.find.all()).hasSize(1); } }); } Which yields the following exception: [info

Play Framework Ebean BigDecimal fraction

為{幸葍}努か 提交于 2019-12-07 03:52:08
问题 I am using the Play Framework with Ebean and H2 database. The problem is, the BigDecimal results in the DB script as: sum decimal(38), but what I want is: sum decimal(38,2), I already tried to define the value in the model like that: @Digits(integer=6, fraction=2) private BigDecimal sum; Any ideas? 回答1: You should use @Column(precision = 38, scale = 2) annotation. @Digits annotation seems to be for validation purposes, not for DDL generation. Also 38 looks like overkill. Are you gonna store