There are a variety of ways to define an entity mapping that only consists of a single identity-based column, such as:
In either case, the generated insert SQL syntax is incorrect.
For Oracle 12c, the generated SQL is
This should probably by rendered instead as
I'm unclear on the exact fix (if any) for SAP Hana.
While it's true, that HANA currently doesn't support inserting a single value into an auto-generated column, it feels to me like throwing a MappingException seems to be too strict. The reason is that Dialect.getNoColumnsInsertString is called while creating the EntityPersister. So now entities mapping to a table with just one auto-generated column block the creation of a session, although the INSERT query may not even be executed.
You can check this behavior, for example, by running org.hibernate.jpa.test.ops.GetLoadTest.
I would prefer not throwing a MappingException and having the user run into a SQL query exception instead, because it doesn't unnecessarily block the creation of sessions.
I think it's ok to notify the user as fast as possible that the INSERT will not work. I only think we should fix the tests and add support in DialectChecks for this. Maybe introduce a new supports method. I'll reopen the issue for this reason.
OK, if you think Hibernate should behave this way, I guess it's fine. I was just pointing out that there might be a use-case for just reading from a table like this without ever inserting data, which isn't possible any more after this fix. I'll think about maybe adding a parameter for switching back to the old behavior.
The only situation when this could happen is if you have an entity with just an identifier. Therefore, in real life, I don't see how you'd end up with such a table.
Once you have at least one property in the entity, the INSERT will work just fine.
I could think of a migrated persistence from another database where this was a valid scenario. A user might be fine just reading from that persistence at first to see if the application can work on HANA. With the fix, a user would have to migrate the application first. But this is probably a corner case that doesn't happen too often.