Search Interview Questions | More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know. |
|
| ||||
Hibernate - Interview Questions and Answers for 'Hibernate' - 92 question(s) found - Order By Newest | ||||
Frequently asked question in companies using Hibernate. | ||||
| ||||
Ans. It's a feature to lazily initialize dependencies , relationship and associations from the Database. Any related references marked as @OneToMany or @ManyToMany are loaded lazily i.e when they are accessed and not when the parent is loaded. | ||||
Sample Code for Lazy Initialization | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate   lazy loading hibernate   lazy initialization hibernate   architecture Asked in 77 Companies Basic   frequent | ||||
Try 2 Question(s) Test | ||||
| ||||
Ans. 1. Set lazy=false in the hibernate config file. 2. Set @Basic(fetch=FetchType.EAGER) at the mapping. 3. Make sure that we are accessing the dependent objects before closing the session. 4. Force initialization using Hibernate.initialize 5. Using Fetch Join in HQL. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate   lazy loading hibernate   lazy initialization hibernate   lazyinitializationexception   architecture Asked in 2 Companies | ||||
Try 2 Question(s) Test | ||||
Frequently asked question in companies using hibernate. | ||||
| ||||
Ans. 1. First level cache is enabled by default whereas Second level cache needs to be enabled explicitly. 2. First level Cache came with Hibernate 1.0 whereas Second level cache came with Hibernate 3.0. 3. First level Cache is Session specific whereas Second level cache is shared by sessions that is why First level cache is considered local and second level cache is considered global. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate   orm   hibernate cache   architecture   technical lead   first level cache vs second level cache Asked in 18 Companies Intermediate   frequent | ||||
| ||||
Ans. @Entity @Table @Id @Column @Temporal @Basic @Enumerated @Access @Embeddable @Lob @AttributeOverride @Embedded @GeneratedValue @ElementCollection @JoinTable @JoinColumn @CollectionId @GenericGenerator @OneToOne @OneToMany @ManyToOne @ManyToMany @NotFound | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate   annotations | ||||
| ||||
Ans. HBM Files ( Mapping ) DB Connection ( DB Connection String , User Name , Password , Pool Size ) SQL Dialect ( SQL variant to be generated ) Show SQL ( Show / No show SQL on Console ) Auto Commit ( True / False ) | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate   configuration   barclays Asked in 11 Companies | ||||
| ||||
Ans. 1. Query Optimization ( Query Rewriting , Prepared Statements ) 2. Restructuring Indexes. 3. DB Caching Tuning ( if using ORM ) 4. Identifying the problems ( if any ) with the ORM Strategy ( If using ORM ) | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   db   database   hibernate   orm   at&t   overstock.com   performance improvement   architecture   technical lead   architect intermediate | ||||
| ||||
Ans. 1. Configure Provider class in Hibernate configuration file. 2. Add Cache usage tag ( read-only or read-write ) in mapping files ( hbm ). 3. Create an XML file called ehcache.xml and place in classpath which contains time settings and update settings, behavior of cache , lifetime and idletime of Pojos, how many objects are allowed. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate   orm   hibernate cache   architecture | ||||
| ||||
Ans. This annotation is added to the auto increment column with the strategy to increment the column value. Usually this is added to the surrogate primary key column and specified with the Database Sequence. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate   hibernate annotations   @generatedvalue   database sequence | ||||
| ||||
This question is still unanswered. Can you please provide an answer. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve   | ||||
| ||||
Ans. 1. No need to know SQL, RDBMS, and DB Schema. 2. Underlying Database can be changed without much effort by changing SQL dialect and DB connection. 3.Improved Performance by means of Caching. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate   orm   architecture | ||||
| ||||
Ans. It tells the framework which SQL varient to generate. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate   orm   hibernate configuration | ||||
| ||||
Ans. Configuration -> SessionFactory -> Session -> Query | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate | ||||
Very frequently asked Hibernate interview question. Frequently asked in TCS ( based on 2 feedback ) | ||||
| ||||
Ans. There are 4 types of associations in Hibernate One to One One to Many Many to One Many to Many | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate   associations Asked in 11 Companies   frequent | ||||
| ||||
Ans. hibernate.cfg.xml ( Main Configuration File ) and *.hbm.xml files ( Mapping Files ) | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate   configuration   mapping files | ||||
| ||||
Ans. Configuration SessionFactory Session Transaction Query and Citeria | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate | ||||
| ||||
Ans. Bag, Set , List , Array, Map | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate | ||||
Very frequently asked if being interviewed for hibernate. Frequently asked in Tata Consultancy (TCS) and Overstock.com | ||||
| ||||
Ans. If id doesnt exist in the DB load throws an exception whereas get returns null in that case.get makes the call to DB immediately whereas load makes the call to proxy. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate Asked in 16 Companies basic   frequent | ||||
| ||||
Ans. We can have the code calling Hibernate API within try block and can have transaction.rollback within Catch. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate   hibernate rollback | ||||
| ||||
Ans. 1. Entity classes should have default constructor. 2. Entity classes should be declared non final. 3. All elements to be persisted should be declared private and should have public getters and setters in the Java Bean style. 4. All classes should have an ID that maps to Primary Key for the table. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate   entity classes hibernate | ||||
| ||||
Ans. Spring caching makes use of its intercepting capabilities to add caching to method calls. Therefore, the entire object is cached and reused. Hibernate, on the other hand, has more domain-specific knowledge of the Entity being cached and can handle the objects more appropriately. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  spring framework   hibernate   spring cache   hibernate cache | ||||
| ||||
This question is still unanswered. Can you please provide an answer. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  JDBC vs JPA  JDBC vs Hibernate | ||||
| ||||
Ans. Evict() and clear(). Evist is used to clear a particular object from the cache whereas clear clears the complete local cache. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate   orm   hibernate cache | ||||
| ||||
Ans. 1. EHCache ( Easy Hibernate ) 2. OSCache ( Open Symphony ) 3. Swarm Cache ( JBoss ) 4. Tree Cache ( JBoss ) | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate   orm   hibernate cache   technical lead Asked in 7 Companies | ||||
| ||||
Ans. No.We can either call evict after the object retrieval or can use separate sessions. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate   orm   hibernate cache   architecture | ||||
| ||||
Ans. Hibernate is a Java ORM Framework. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate   orm   frameworks   architecture | ||||
| ||||
Ans. Table Per Class , Table per Sub Class , Table per Concrete Class | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate   orm   inheritance hibernate Asked in 1 Companies Basic   frequent | ||||
| ||||
Ans. Lazy fetching is the technique of not loading the child objects when parent objects are loaded. By default Hibernate does not load child objects. One can specify whether to load them or not while doing the association. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate   lazy fetching   architecture Asked in 11 Companies   frequent | ||||
Try 2 Question(s) Test | ||||
| ||||
Ans. Transient - In this state, an instance is not associated with any persistence context Persistent - In this state, an instance is associated with a persistence context Detached - This is a state for an instance which was previously associated with a persistence context an has been currently closed dissociated | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate | ||||
| ||||
Ans. Static and Transient. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate   orm | ||||
| ||||
Ans. We configure Entity classes having annotated mappings. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate   hibernate annotations | ||||