where to put .propertie files in eclipse


  1. Basically, JVM  reads  the properties files from the classes folder in the Web project once we deployed into the server
  2. If we create the Web project in eclipse IDE ,we have to put the properties files in the src folder like below



so,when we deploy the above project in server, properties files will be placed in classes folder automatically


Java Project

If we create Normal Java Project properties files should be in project root folder.


Maven Project

If we create Maven Project properties files should be in resources folder.






Basically This exception occurs when we use Relationships(OneToOne,OneToMany,ManyToMany) between the Two Objects and not provide the cascade  types.

So if you get the following exception add

@ManyToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY) etc...

Exception in thread “main” org.hibernate.TransientObjectException: object references an unsaved transient instance – save the transient instance before flushing: org.shashank.Users (for Ex:)
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:243)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java:456)
at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:121)
at org.hibernate.persister.collection.AbstractCollectionPersister.writeElement(AbstractCollectionPersister.java:815)
at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1203)
at org.hibernate.action.CollectionRecreateAction.execute(CollectionRecreateAction.java:58)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:188)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:133)


Exact Meaning of Class.forName(); in JDBC

Before going to discuss, need to discuss about Drivers. Inorder to connect a  java Application  with database ,  we need to follow the below important steps

  1. Use any JDBC  Driver class.
  2. This JDBC Driver class has to be instantiated.
  3. And Instantiated Driver class should be Registered with DriverManager class

For Example:

Let’s take Type1-Driver(sun.jdbc.odbc.JdbcOdbcDriver) which comes with JDK by Default So Inorder to connect  a java application with  database with this driver we have to write following statements.

sun.jdbc.odbc.JdbcOdbcDriver driver=new sun.jdbc.odbc.JdbcOdbcDriver();


Ok.Then what is Class.forName(“com.Anyclass”) ? Basically Class.forName("com.Anyclass");   used to load a class. while loading a class, if that class contains static blocks, and any code which is in that static blocks,  will be executed. So if write a statement  for Ex:      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");  code in static block of this driver will be executed while class is loading. All most all JDBC drivers contains static blocks and these static block contains the code to 1) Instantiate the driver class 2) Register the driver with DriverManager.

Following  is the  static block in JdbcOdbcDriver


JdbcOdbcTracer jdbcOdbcTracer= new JdbcOdbcTracer();

jdbcOdbcTracer.trace("JdbcOdbcDriver class loaded");
JdbcOdbcDriver driver=new JdbcOdbcDriver();
catch(SQLException sqlException){
           jdbcOdbcTracer.trace("Unable to register Driver");


Class.forName(“com.any.Driver”);    Internally  loads the Driver class, while loading the class

  1. It instantiates the Driver class
  2. Register the Driver class with DriverManager.