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

  • Home
  • SEARCH
  • 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 219239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:49:34+00:00 2026-05-11T18:49:34+00:00

Consider the following hibernate configuration: <class name=Person> <id name=id column=personId> <generator class=native/> </id> <set

  • 0

Consider the following hibernate configuration:

<class name="Person">
<id name="id" column="personId">
    <generator class="native"/>
</id>
<set name="addresses" table="PersonAddress">
    <key column="personId"/>
    <many-to-many column="addressId"
        class="Address"/>
</set>
</class>

<class name="Address">
<id name="id" column="addressId">
    <generator class="native"/>
</id>
<set name="people" inverse="true" table="PersonAddress">
    <key column="addressId"/>
    <many-to-many column="personId"
        class="Person"/>
</set>
</class>

Now, these two classs (Person and Address) have an Auditable interface. In our Hibernate AuditInterceptor class (implements Interceptor), we perform some auditing function if the entity is an instanceof Auditable. In short, all of this code works great…

However, there’s this PersonAddress table that doesn’t get audited because we don’t technically have a POJO for it…so we can’t check for some “instanceof”. Is there any way in the hibernate configuration that we can tell it to Intercept this PersonAddress table? Maybe we need to handle one of the other actions from the Interceptor (like onCollectionUpdate). I’m not sure…

The only other way I can think to force it to Audit is to convert the relationship to a one-to-many from Person to PersonAddress, one-to-many from Address to PersonAddress and create another class element for PersonAddress that does the many-to-one mappings back to Person and Address.

That seems kind of like extra work and I really want to avoid extra work.

Can somebody suggest a better solution?

Thanks!

  • 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-11T18:49:35+00:00Added an answer on May 11, 2026 at 6:49 pm

    I couldn’t figure it out via many-to-many mappings, so I converted that mapping into a one-to-many and created a model bean for PersonAddress with appropriate hibernate mappings.

    Thanks!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following Hibernate mappings: <hibernate-mapping package=org.example> <class name=Customer table=CUSTOMER> <id name=customerId column=customer_id/> <bag
Consider the following Hibernate mapping file: <hibernate-mapping ...> <class name=ContentPackage table=contentPackages> <id name=Id column=id
Please consider the following two entities: @Entity @Table(name = PROFILE) public class Profile extends
I am using Hibernate 4.1 and Spring 3.1. Consider the following User class having
Consider the following three Hibernate entities: public class Car { @OneToMany(fetch = FetchType.LAZY) @Fetch(FetchMode.SUBSELECT)
Consider following MySQL table: CREATE TABLE `log` ( `what` enum('add', 'edit', 'remove') CHARACTER SET
Consider following 2 programs giving same error First calss: public class Testing { Testing
I m not very versed in Hibernate and have following query: Consider two classes:
Consider following tables: How to skip and take groups from the table? Tried using
Consider following example: class CBase abstract { protected: CBase() { } }; I could

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.