Activities carried on by session interface are handling persistence phases, retrieving the persisted ones, and transaction separations management.ĥ. Hibernate session which performs database entities manipulation is represented by session interface. What are the two cache types in Hibernate?įirst level cache and Secondary level cache are the types of cache in Hibernate. Set, Map, Bag, List and Array are the different types of collections in Hibernateģ. Provide the list of collection types in Hibernate? ORM is helpful in automatically generating keys, managing transaction, hiding SQL queries details, and developing applications in quick manner.Ģ. All classes should have an ID that maps to Primary Key for the table.HIBERNATE Interview Questions for freshers experienced :. All elements to be persisted should be declared private and should have public getters and setters in the Java Bean style.Ĥ. Entity classes should be declared non final.ģ. Entity classes should have default constructor.Ģ. What are the restrictions for the entity classes ?Īns. Declaring entity classes as final will prohibit communication with database lazily and hence will be a performance hit. Yes but as Hibernate creates the Proxy Classes inherited from the Entity Classes to communicate with Database for lazy initialization. Can we declare Entity class as final ?Īns. After which Hibernate version, related Entities are initialized lazily ? Which type of associated Entities are Eagerly loaded by Default ? Detach, Merge, Persist, Remove, Refresh What are the different Cascade types ?Īns. Instead of Saving Parent as well as Child Entities individually, Hibernate provides the option to persist / delete the related entities when the Parent is persisted. Make sure that we are accessing the dependent objects before closing the session.Īns. Set lazy=false in the hibernate config file.ģ. What are the ways to avoid LazyInitializationException ?Īns. Any related references marked as or are loaded lazily i.e when they are accessed and not when the parent is loaded. It's a feature to lazily initialize dependencies, relationship and associations from the Database. What is Lazy Initialization in Hibernate ?Īns. Lazy = false in hibernate config at the mapping What are the different ID generating strategies using annotation ?Īns. Third Annotations will set the different names for Enitity and Table and will explicitly map them. The second annotation will make the Entity mapped to table EMPLOYEES irrespective of the Entity Name ( which is class name in this case ). First Annotation will set the Entity name as EMPLOYEES and hence will try to map with the same Table name. "What is the difference between these 2 annotations ( name ( name=""EMPLOYEES"" ( ( name="EMPLPYEES" )Īns. The first annotation will try to map the Class with the Table as of same name as Class whereas the second annotation will specify the Entity name as "EMPLOYEES" and hence will try to map with Table Name "EMPLOYEES". What is the difference between these 2 annotations ( name="EMPLOYEES" )Īns. "update" doesn't create the table if it's not found whereas configuration set as "create" creates the schema automatically. This configuration specifies if hibernate should creates the Schema / Table on its own if the respective table is not found. What is the use of hbm2ddl Configuration in Hibernate ?Īns. We can have the code calling Hibernate API within try block and can have transaction.rollback within Catch. What is the way to rollback transaction if something goes wrong using hibernate API ?Īns. Hibernate creates new Session object per thread. Single SessionFactory object and multiple session objects for opening different session. How many SessionFactory and Session objects are usually created ?Īns. We configure Entity classes having annotated mappings. Name few Hibernate annotations What entries we make in the hibernate config file if we are not using hbm files but Annotations ?Īns. Detached - This is a state for an instance which was previously associated with a persistence context an has been currently closed dissociated
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |