Re: [h2] Data Inconsistencies between H2 DB and the generated SQL

2018-01-27 Thread Kerry Sainsbury
The column with the 'wrong' value is not an auto-increment column, so
auto-increment isn't likely to be the problem.
Most likely explanation is that something else has changed parent_id from 6
to 2, after the original insert.

On 25 January 2018 at 15:50, Anerudh Balaji  wrote:

> Hey all,
>
> While using Hibernate w/ H2, we ran into this weird case today where the
> H2 primary Id for an entity and the generated SQL Id for the same entity
> had a mismatch. Been struggling with this one for a while and any help
> would be appreciated !
>
>
> Here's the Java class that we have (Cut out irrelevant portions of the
> code) :
>
> 
> 
>
> @Entity(name="some_entity")
> @Table(name = "table_name")
> @EqualsAndHashCode
>
> public class ProblemClass implements Serializable {
>
>
> private long identifier;
>
>
> private ProblemClass parent;
>
>
> @Override
> @Id
> @GeneratedValue
> @Column(name = "identifier")
> public long getIdentifier() {
> return id;
> }
>
> public void setIdentifier(long identifier) {
> this.id = id;
>
>
> }
>
> @Nullable
> @ManyToOne(fetch = FetchType.EAGER)
> @JoinColumn(name = "parent", referencedColumnName = "identifier")
> public ProblemClass getParent() {
> return parent;
> }
>
> public void setParent(@Nullable ProblemClass parent) {
> this.parent = parent;
> }
>
>
> 
> 
> 
>
> Here's the H2 creation code that we have :
>
> CREATE TABLE table_name (
>   `identifier` bigint(10) NOT NULL auto_increment,
>
>   `parent_id` bigint(10) DEFAULT NULL,
>
>
> ...
>
> }
>
>
> ///
>
>
>
> The data generation used to work absolutely fine till today when the
> generated sql and the SQL when I use the H2 to inspect didn't match the
> parentId that was being referred to.
>
> For example, In the SQL file we found this statement : INSERT INTO
> PUBLIC.TABLE_NAME(identifier, parent_id) VALUES
> (1, 1)
> (2, 1)
> (3, 6)
> ...
>
> But in the H2 database, we found this (when I do select * from TABLE_NAME)
>
> (1, 1)
> (2, 1)
> (3, 2)
>
>
> Eventually, this led to a *org.hibernate.ObjectNotFoundException: No row
> with the given identifier exists* issue while retrieving a row, whose Id
> number doesn't exist in the DB.
>
>
>
> *Questions* :
>
> 1) Am I doing something incorrect/invalid ?
>
> 2) How could the generated SQL (using Hibernate's SessionImpl) and the H2
> DB values be different ? (Previously, it used to be the exact same -
> whatever was observed on the generated SQL files was what got inserted into
> the H2 db)
>
> 3) Are there any known issues with the auto_increment feature on H2 ?
>
>
> Thanks a ton!
>
> Cheers,
> Anerudh
>
> --
> You received this message because you are subscribed to the Google Groups
> "H2 Database" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to h2-database+unsubscr...@googlegroups.com.
> To post to this group, send email to h2-database@googlegroups.com.
> Visit this group at https://groups.google.com/group/h2-database.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to h2-database+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.


Re: [h2] compacting an embedded h2 database

2018-01-27 Thread Kerry Sainsbury
Is it feasible to create a new empty database?

On 26 January 2018 at 01:53, Famco  wrote:

> I am using the database in embedded mode, so  trieing to execute "shutdown
> compact" does not work (I waited 15 minutes on an 1GB File)
> For me it looks like H2 is NOT reusing empty space.
> Is there any other way to force the h2 stop from growing?
>
>
>
>
>
> Am Donnerstag, 25. Januar 2018 13:18:12 UTC+1 schrieb Noel Grandin:
>>
>> http://h2database.com/html/features.html#compacting
>>
> --
> You received this message because you are subscribed to the Google Groups
> "H2 Database" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to h2-database+unsubscr...@googlegroups.com.
> To post to this group, send email to h2-database@googlegroups.com.
> Visit this group at https://groups.google.com/group/h2-database.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to h2-database+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.