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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:35:51+00:00 2026-05-21T19:35:51+00:00

There are lots of Q&A’s about the size of a Java object, which is

  • 0

There are lots of Q&A’s about the size of a Java object, which is quite straightforward to understand. But I’m wondering about the size of a Java class in the PermGen space.

The reason I wonder about this is because I’m writing a code generator, generating a lot of classes. Essentially, I’m generating two classes for every table/view in a database. Now I also want to model foreign key relationships. Instead of maintaining a complex, serialisable object-structure (think about a table having a unique key being referenced by several foreign keys belonging to other tables having other foreign keys, etc), I’d prefer to generate one class per UNIQUE KEY and one class per FOREIGN KEY.

Here are my questions:

  1. How much overhead on the classloader and the PermGen space will I create with this?
  2. Is there a difference between public classes, static classes and private member classes?
  3. Do you see a better way to generate foreign key information in source code?
  • 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-21T19:35:52+00:00Added an answer on May 21, 2026 at 7:35 pm

    I found a different solution, not wasting as much memory as generating one class per KEY. I generate a single class that roughly looks like this:

    public class References {
    
        // First, initialise all unique keys
        public static final UniqueKey<TAuthorRecord> SysPk_14655 = 
            createUniqueKey(TAuthor.T_AUTHOR, TAuthor.ID);
    
    
        // Then initialise all foreign keys
        public static final Reference<TBookRecord, TAuthorRecord> SysFk_14666 = 
            createReference(SysPk_14655, TBook.T_BOOK, TBook.AUTHOR_ID);
        public static final Reference<TBookRecord, TAuthorRecord> SysFk_14667 = 
            createReference(SysPk_14655, TBook.T_BOOK, TBook.CO_AUTHOR_ID);
    
    
        // Factory method for unique keys
        protected static <R extends Record> UniqueKey<R> 
        createUniqueKey(Table<R> table, TableField<R, ?>... fields) {
    
        // Factory method for foreign keys referencing unique keys
        protected static <R extends Record, U extends Record> Reference<R, U> 
        createReference(UniqueKey<U> key, Table<R> table, TableField<R, ?>... fields) {
    
    }
    

    The actual tables from the generated table classes can then reference and use the above keys. I looked into JPA annotations as suggested by BobG in one of his comments. But I didn’t find them very useful to describe:

    • Multi-field keys (@IdClass needs a type as parameter, and I want to avoid that type)
    • Multi-field references (how to do it?)
    • Multiple references from one table to another table using different keys
    • Unique keys, which share many properties with the primary key.

    Some of the comments mentioned why I should create such a generator, because there are lots of established frameworks. I’m doing this for http://www.jooq.org. And I feel jOOQ is filling a gap in today’s database abstraction possibilities.

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

Sidebar

Related Questions

There are lots written about the ReaderWriterLockSlim class which allows multiple read and a
There are lots of java apps on my simulator menu screen which I have
There are lots of questions about this but I've not been able to solve
So I have these classes. There's one base class, but it has/will have lots
There are lots of pages on stackoverflow about destorying session. Trust me, I have
There are lots of stringify_keys questions here, but i can't find proper match to
There are lots of implementations for validating Luhn checksums but very few for generating
There are lots of tutorials/instructions on how to embed python in an application, but
There are lots of questions on how to strip html tags, but not many
There are lots of similar questions to this, but they all seem to involve

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.