h2

On duplicate key update feature in H2

一笑奈何 提交于 2019-12-05 20:44:37
问题 I have developed java desktop application with the use of H2(Embedded). I just have basic knowledge about database, so i simply installed H2 and create a schema name RecordAutomation and then add tables to that schema. Now i am trying to use the ON DUPLICATE KEY UPDATE feature for a specific table which is not working giving sql syntax error, i check my query i found it right, given below INSERT INTO RECORDAUTOMATION.MREPORT (PRODUCTID ,DESCRIPTION ,QUANTITY ,SUBTOTAL ,PROFIT ) VALUES (22

H2 not creating/updating table in my Spring Boot app. Something's wrong with my Entity?

限于喜欢 提交于 2019-12-05 20:31:17
问题 I want to keep some data in H2 database by making a CRUD repository, using Hibernate. I can't get the database to store my entries whatsoever. Currently, I'm trying to achieve that during updating the db by making a sample entry. Entry is looking good in the logs, but table is not created/updated/generated. Why Hibernate is not unable to create a table in this case? (if the problem lies in structure of my data) Here's my Entity, Game.java class (I've tried without @Column annotations, no

How to persist a Map<String, List<Object>> in Hibernate

…衆ロ難τιáo~ 提交于 2019-12-05 20:04:30
I've got a Map containing MyObject instances. The MyObject class uses JPA to persist its fields: @OneToMany(cascade = CascadeType.ALL) @LazyCollection(LazyCollectionOption.FALSE) private Map<String, MyObject> results = new HashMap<String, MyObject>(); We changed the value stored by the Map to a List : private Map<String, List<MyObject>> results = new HashMap<String, List<MyObject>>(); But upon launching we receive a stack trace: Caused by: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: com.me.myapp.MyObject.results[java.util.List] at org

transactions not working with Spring 3.1 – H2 – junit 4– hibernate 3.2

老子叫甜甜 提交于 2019-12-05 19:48:09
I have the following test.. @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"/schedule-agents-config-context.xml"}) @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true) @Transactional public class H2TransactionNotWorkingTest extends SubmitAgentIntegratedTestBase { private static final int FIVE_SUBMISSIONS = 5; @Autowired private ApplicationSubmissionInfoDao submissionDao; private FakeApplicationSubmissionInfoRepository fakeRepo; @Before public void setUp() { fakeRepo = fakeRepoThatNeverFails(submissionDao, null);

Play framework 2.0.1 keeps trying to evolve wrong database type

那年仲夏 提交于 2019-12-05 18:45:28
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 integer not null, constraint pk_gif primary key (id)) ; create table task ( id bigint not null, action

H2 “runscript” command turns all table names into uppercase

旧时模样 提交于 2019-12-05 17:24:42
问题 I have a sql script (it is just schema definition). The script is a modified version (getting rid of the bad characters h2 doesn't like) of a mysql dumb. The script runs and the schema is inserted into the h2 database, but the issue is that all of the database names are in uppercase ('xyz' gets converted to 'XYZ'). I need them to stay in lowercase because my application is looking for the lowercase (and all of the tables in the mysql db are lowercase). Why is this happening? How can I tell h2

Conditional Unique index on h2 database

人走茶凉 提交于 2019-12-05 17:10:31
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? 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) unique ); --works insert into test(biz_id, active) values(1, 0); insert into test(biz_id, active) values(1,

Setup password for H2

流过昼夜 提交于 2019-12-05 16:04:11
问题 How to set up my own password for accessing the h2 while working in embedded mode? (if anyone confused - talking about the root password for accessing the database) In Eclipse it seems that password assignment occurs at the moment of db connection creation which in turn launches the process of schema creation, where we provide username and password. Even if this is true how to change existing password after set up? I've searched in information schema - found `users', there is no password

How to CREATE PROCEDURE in H2

帅比萌擦擦* 提交于 2019-12-05 15:20:49
问题 This seems to be a duplicate of the other question with the same title, but it actually isn't. We have our business logic implemented mostly as DB2 stored procedures (I see that H2 has a DB2-compatibility mode - nice!). How can we use H2 for in-memory unit testing with these procedures? Unfortunately H2 seems to lack the CREATE PROCEDURE command from its grammar. I don't want to use Java functions as stored procedures. It would be best if the very same sql files could be used for testing and

TO_CHAR function not available in H2 database

风流意气都作罢 提交于 2019-12-05 14:21:34
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. Use the newer version 1.3.175. Since 2014-01-18 available with a TO_CHAR function. You could try HSQLDB of course. I think it does support TO_CHAR. Or you could write a user defined