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. |
|
| ||||
Interview Questions and Answers - Order By Rating | ||||
| ||||
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   | ||||
| ||||
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. First resolution is a big No as it conveys no lazy loading in complete app. even second is advocating the same but for a particular mapping. third one is most appropriate if loading and dependent entity property access is closer to each other in code and can be accomplished. I don't mind using 4th too. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  lazy loading  lazy initialization  LazyInitializationException | ||||
| ||||
Ans. The error states that Hibernate is not able to initialize proxy / dependent entity objects as there is no session or transaction present. Very likely we are trying to load the dependent entities lazily but the call to dependent object property is not wrapped within the session or transaction. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  Lazy Loading  Lazy Initialization  org.hibernate.LazyInitializationException | ||||
| ||||
Ans. a | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve   | ||||
| ||||
Ans. We can use @AccessType("property") for getDepartmentId() method within Department class in that case. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve   | ||||
| ||||
Ans. No, it's not legal in hibernate. 1 column should be mapped to only one field in entity. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve   | ||||
| ||||
Ans. JDBC ( Java Database Connectivity ),ODBC (Open Database Connectivity), Hibernate, JPA ( Java Persistence API ), JOOQ,MyBatis | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  database connection  jdbc  ORM  Hibernate Asked in 1 Companies | ||||
| ||||
Ans. It specifies an association fetching strategy. It could be DEFAULT, JOIN or SELECT as following @Fetch(FetchMode.SELECT) | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve   | ||||
| ||||
Ans. Save is used to save the entity to the session whereas flush is to save the session content to DB. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve   | ||||
| ||||
Ans. Lazy Initialization means , Load Dependencies when required. Which means less load on application resources as only required data is loaded upfront. It's not only good for better performance but for better resource utilization too. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  lazy loading  lazy initialization   frequent | ||||
| ||||
Ans. Make sure that the properties of dependent Hibernate entities are not accessed and if yes, better wrap the whole code within single transaction. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  lazy loading  lazy initialization | ||||
| ||||
Ans. // Non-managed environment idiom Session sess = factory.openSession(); Transaction tx = null; try { tx = sess.beginTransaction(); // do some work ... tx.commit(); } catch (RuntimeException e) { if (tx != null) tx.rollback(); throw e; // or display error message } finally { sess.close(); } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve   Asked in 1 Companies | ||||
| ||||
Ans. No, Every entity in hibernate needs to have a key, either primary or composite. If we dont have a primary key on table, there are various ways this problem can be countered. 1. By using composite key on entity ( make sure that the appropriate unique constraint in defined on columns in Database ) 2. By mapping Id in entity to ROWID of table. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate entity  hibernate | ||||
| ||||
Ans. JDBC is a standard Java Api for Database communication whereas Hibernate is an ORM framework that uses JDBC to connect with Database. Hibernate is another layer of object table mapping over JDBC that provide a database independent, object oriented and an efficient way of database communication. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  JDBC  Hibernate  JDBC vs Hibernate Asked in 3 Companies | ||||
| ||||
Ans. session.createCriteria(Employee.class).add( Restrictions.or(Restrictions.like("name", "A%"),Restrictions.like("name", "B%"))).list(); | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate  Criteria  Restrictions | ||||
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. 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. 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. 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. 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. 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. 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. 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. 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 | ||||