Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6639363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:32:44+00:00 2026-05-25T23:32:44+00:00

Say I have a table like so: CREATE TABLE big_table (UUID varchar(32) not null,

  • 0

Say I have a table like so:

CREATE TABLE big_table (UUID varchar(32) not null, ... );

I have a query on the table that I can’t express as an HQL or Criteria query. I am trying to set up the query as view in Oracle, like so:

CREATE VIEW big_table_view AS SELECT bt.* FROM big_table bt
    LEFT OUTER JOIN ...
        -- (multicolumn subselect over big_table for some historical stuff)
    WHERE ...

I am trying to map the same Java class to both the table and the view. That would be really cool because then I can run the same Criteria queries against both, etc.

My problem is that I can’t come up with an HBM mapping file that doesn’t wreak havoc with my HSQLDB test code. My test setup is a typical Maven/Spring test setup with hibernate.hbm2ddl.auto set to create-drop so that Hibernate creates the HSQLDB schema on the fly for testing.

My mapping file currently looks like this:

<hibernate-mapping>
    <class name="com.example.BigPojo" entity-name="bigPojo"
            table="big_table">
        &commonPropertiesEntity;
    </class>

    <class name="com.example.BigPojo" entity-name="bigPojoView"
            table="big_table_view">
        &commonPropertiesEntity;
    </class>
</hibernate-mapping>

…when I run my tests, they blow up all over the place because HSLQDB is trying to create a table called big_table_view with all the same foreign key constraints, indices, etc. I’m trying to fix the schema after it gets created via a database-object element like this:

<database-object>
    <create>
        DROP TABLE big_table_view CASCADE;
        CREATE VIEW big_table_view...
    </create>
    <drop>
        DROP VIEW big_table_view IF EXISTS;
    </drop>
    <dialect-scope name="org.hibernate.dialect.HSQLDialect" />
</database-object>

…but there’s still something breaking and I’m still wading through trying to figure it out. Is there a way to tell Hibernate to exclude the bigPojoView entity from hbm2ddl? Is there a better way to do this mapping generally? I’m open to any advice…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:32:45+00:00Added an answer on May 25, 2026 at 11:32 pm

    There’s no easy way to exclude a table from hbm2ddl. You can, however, map your view via Hibernate’s subselect: see footnote #20 under 5.1.1.

    Something like:

    <class name="com.example.BigPojo" entity-name="bigPojoView"
        <subselect>
          ... your view definition here ...
        </subselect>
        <synchronize table="big_table"/>
        <id name="UUID"/>
        ...
    </class>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a table like this: CREATE TABLE t( [guid] [uniqueidentifier] NOT
Say I have a table like this: create table users ( user_id int not
Let's say I have a payments table like so: CREATE TABLE Payments ( PaymentID
Let's say I have a MySQL table that is something like this: software table:
SQL Server 2000 Say if I have a table like CREATE TABLE [Message] (
Let's say I have a table of users set up like this: CREATE TABLE
I have a table of values like this: CREATE TABLE ( Name1 VARCHAR (50),
Lets say i have a table like this: col1 col2 col3 row1 1 null
Let's say I have two Databases like so : DatabaseA create table Table1 (
I have a table (Oracle database) that looks like: CREATE TABLE example ( idEx

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.