Common JPA explanations

**This is just for reference only, most of the source of these infor is taken from stackoverflow. 

When to use eager loading

  1. In "one side" of one-to-many relations that you sure are used every where with main entity. like User property of an Article. Category property of a Product.
  2. Generally When relations are not too much and eager loading will be good practice to reduce further queries on server.

When to use lazy loading

  1. Almost on every "collection side" of one-to-many relations. like Articles of User or Products of a Category
  2. You exactly know that you will not need a property instantly.

https://stackoverflow.com/questions/31366236/lazy-loading-vs-eager-loading


Could not connect to the database. Exiting now... MongooseServerSelectionError: connection timed out

 Getting the following error in AWS, while trying to run node js docker container


[2022-12-19T19:03:56.378] [ERROR] server:825 Could not connect to the database. Exiting now... MongooseServerSelectionError: connection timed out

    at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:825:32)

    at /app/node_modules/mongoose/lib/index.js:417:10

    at /app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:41:5

    at new Promise (<anonymous>)

    at promiseOrCallback (/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:40:10)

    at Mongoose._promiseOrCallback (/app/node_modules/mongoose/lib/index.js:1270:10)

    at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:416:20)

    at Object.<anonymous> (/app/server.js:30:10)

    at Generator.next (<anonymous>) {

  reason: TopologyDescription {

    type: 'Unknown',

    servers: Map(1) { '3.129.14.175:27017' => [ServerDescription] },

    stale: false,

    compatible: true,

    heartbeatFrequencyMS: 10000,

    localThresholdMS: 15,

    setName: null,

    maxElectionId: null,

    maxSetVersion: null,

    commonWireVersion: 0,

    logicalSessionTimeoutMinutes: null

  },

  code: undefined



Make sure that the node.js app configuration uses the white listed mongo db internal IP address.

Common JPA explanations

**This is just for reference only, most of the source of these infor is taken from stackoverflow.  When to use eager loading In "one si...

Popular in last 30 days