Hibernate Delete using HQL – QuerySyntaxException: Foo is not mapped

The entity name needs to be used in the query instead of the table name.

 

For example this causes the QuerySyntaxException as it uses the database table name in the query:

 

Query query = session.createQuery(“delete from product¬†where venue_id = :venueID”);
query.setParameter(“venueID”, venueID);

The below query works as it uses the entity name:

Query query = session.createQuery(“delete from ProductEntity¬†where venue_id = :venueID”);
query.setParameter(“venueID”, venueID);

Auto Incrementing an SQL column which doesnt have the AUTO INCREMENT constraint

You need to use a sequence. You can see the available sequences in a schema in Squirrel SQL. These sequences can be auto generated or manually created. A sequence is generated automatically when you make a column on any table auto increment. This is the case for the 'SYSTEM_SEQUENCE_XX..' below. The other sequences were manually written.


sql-sequence-screenshot

The list of sequences seen below the tables

The syntax for inserting into a table which has an id whcih cant be null and needs to increment, but which doesnt have an auto increment constraint, is below:

INSERT INTO AUTHORITY(order_id, foo1, foo2, foo3)SELECT AUTHORITY_PK_SEQ.nextval,foo1, foo2, foo3
                                FROM bar
                                WHERE X = Y

SQL Join Two Result Sets / Join Two Select Statement Results into one Result Set

Thanks to Mark Byers on Stack Overflow.


SELECT T1.col_a, T1.col_b, T2.col_c
FROM(SELECT col_a, col_b,...etc...)AS T1
JOIN(SELECT col_a, col_c,...etc...)AS T2
ON T1.col_a = T2.col_a

Error 1723 cant unstall Java due to missing DLL

Download the Windows Installer Cleanup from here. Worked a treat.