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 6082957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:20:49+00:00 2026-05-23T11:20:49+00:00

I’m dealing with an existing table of events: Event Table: id event_type status …

  • 0

I’m dealing with an existing table of events:

Event Table:
id    event_type          status    ...
==    ==========          ======
 1    high.temperature    ACCEPTED
 2    missing.invoice     WAITING
 3    missing.invoice     WAITING

Currently there are a few hundred event_types and five status. This table has millions of rows, and I would like reduces its size by using lookup tables for event_type and status. status is fine, since it has a small number of static values, but event_type is controlled by external systems and events are sometimes received by my system with new values that will have to be added to the lookup tables.

I believe the existing table structure was chosen to make mapping with hibernate easy, which it does quite well, but results in a lot of redundancy.

What I want is something like this:

Event Table:
id    event_type    status   ...
==    ==========    ======
 1    223           3
 2    245           4
 3    245           4

EventType Table:
event_type    name  
==========    ================  
223           high.temperature
245           missing.invoice

My question is, is there any way to automate inserts and selects to/from the lookup table, so that I don’t have have to define a Java class for EventType and and lookup the appropriate EventType every time I insert into Event? On the java side, I would prefer to treat the event_type as a plain String, as it is now.

  • 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-23T11:20:49+00:00Added an answer on May 23, 2026 at 11:20 am

    Read operations shouldn’t cause any problem : create an EventType entity, add a private eagerly-fetched many-to-one relationship between Event and EventType, put EventType in the second-level cache, and add a getter returning the event type’s name in Event. This makes it transparent to the rest of the application, and doesn’t cause additional selects thanks to the second-level cache.

    Insertion is harder, though, because you probably don’t want to make your entities access the session to make new event types persistent. And even if this it was acceptable, I guess you’d want to have a unique constraint for the event type name, which could make some event creations fail if two events with the same new event type are created in parallel.

    I would create a service which would “get or create” an event type based on a name. This service would use a dedicated transaction to create the event type in order to reduce the probability of conflicts. And I would use this service each time I need to assign an event type to an event (which, I guess, should be much less frequent than reading an event’s type).

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small

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.