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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:57:55+00:00 2026-06-14T11:57:55+00:00

Sometimes I have problems using my BD At Work. Usually is when i try

  • 0

Sometimes I have problems using my BD At Work. Usually is when i try to recover or update a table in Java with the session closed (the famous LazyInitializatioException ).
And at the end, sometimes the problem is that exists a foreign key pointing to a value of a non existing primary key index. When it happens, the lazy entity doesn’t load correctly.

So, is there a way to check if a table data has foreign keys indexes set to non existing primary keys ?

For a single column would be easy. But I mean for tables with about 10 or 20 foreign keys.

Im using postgres. If thats an answer especificaly for it it’d be much better. =]

Sorry for my bad English (not native).

  • 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-06-14T11:57:56+00:00Added an answer on June 14, 2026 at 11:57 am

    I’m not familiar with Java and those errors you mentioned.
    Best solution is to have foreign key constraints created in db which do not allow to remove record if is referenced from another table.

    If you must try:

    select some_columns
    from table1 t1 left join table2 t2 on (t1.id1 = t2.table1_id1)
    where t2.id is null
    limit 1
    

    to check if such records exists.
    If those tables are big there is no fast solution(usually ends with full table scan).

    There is also possibility to do cascade delete or set null automatically using foreign key constraint. Read FOREIGN KEY part in postgresql docs

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

Sidebar

Related Questions

At my work sometimes I have to merge from few to few hundreds pdf
I have problems with a specific query when using the sqlite3_step function: SELECT DISTINCT
I have several problems with the interface builder in Xcode 4. I am using
Do you know any documentation about the rules of using update sites? I have
I have some problem with MySQL Workbench in that I sometimes can't set foreign
I have a problem in a site that I am trying to develop Sometimes
I have a service that also contains an activity the problem is sometimes it
I see on sites that they sometimes have a statistic showing how many views
Our build workflows are a bit involved in the sense they sometimes have to
I'm testing out the OpenERP 6.1 web client, and I sometimes have a sales

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.