Die meistgefragten Interviewfragen und Antworten sowie Online-Tests
Lernplattform fur Interviewvorbereitung, Online-Tests, Tutorials und Live-Ubungen

Baue deine Fahigkeiten mit fokussierten Lernpfaden, Probetests und interviewreifem Inhalt aus.

WithoutBook vereint themenbezogene Interviewfragen, Online-Ubungstests, Tutorials und Vergleichsleitfaden in einem responsiven Lernbereich.

Interview vorbereiten

Probeprufungen

Als Startseite festlegen

Diese Seite als Lesezeichen speichern

E-Mail-Adresse abonnieren
WithoutBook LIVE Mock Interviews
The Best LIVE Mock Interview - You should go through before interview

Freshers / Beginner level questions & answers

Ques 1. What is JPA?

JPA (Java Persistence API) is a Java EE and Java SE specification that describes a management system for saving java objects to relational database tables in a convenient form.

Java itself does not contain JPA implementations, however, there are many implementations of this specification from different companies (open and not). This is not the only way to save java objects in databases (ORM systems), but one of the most popular in the Java world.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 2. What is JPA and its features?

Java Persistence API (JPA) is a collection of classes and methods to persistently store vast amounts of data in a database which is provided by the Oracle Corporation.
The Java Persistence API (JPA) is now here to simplify the developer's life. Developers can now use the JPA API to develop applications easily. Here are the features of JPA:
  • JPA supports pluggable, third-party persistence providers such as Hibernate and TopLink, etc.
  • JDK 11 annotations are fully supported.
  • Few java classes are required to develop persistence applications.
  • JPA application can run outside the container also. So, developers can use JPA capabilities in desktop applications also.
  • No need to write deployment descriptors. Annotations-based meta-data are supported in JPA applications.
  • Annotation defaults can be used in the model class, which saves a lot of development time.
  • Provides cleaner, easier, standardized object-relational mapping.
  • JPA supports inheritance, polymorphism, and polymorphic queries.
  • JPA also supports named (static) and dynamic queries.
  • JEB QL is a very powerful query language provided by JPA.
  • JPA helps you build a persistence layer that is vendor-neutral and any persistence provider can be used.
  • Many IDEs are also available to ease the development of JPA applications.
  • Some IDEs can generate the model and persistence code from the database schema.
  • JPA application can also be configured to generate database schema based on the persistence model.
  • It is also very easy to switch to the most performing persistence provider. You can easily move to any commercial persistence provider.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 3. Why to use JPA?

  • JPA is the standard, and standards are good!
  • Using JPA does not tie you to Hibernate.
  • JPA gives you most of the features of plain old Hibernate, except:
  • No criteria queries in JPA 2.0. Criteria query is a neat feature of Hibernate that constructs queries using Java-based combinators instead of the alternate query language, getting the benefit of IntelliSense and Eclipse's refactoring tools.
  • JPA doesn't have Hibernate's DeleteOrphan cascade type.
  • Delete Orphan is a useful annotation that directs Hibernate to delete entities in a collection if the parent is deleted, preventing orphaning.
  • JPA doesn't have an equivalent to Hibernate's ScrollableResults.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 4. What is ORM in JPA?

Mapping between database tables and java objects called ORM (Object Relational Mapping). JPA (Java Persistence API) provides and ORM facility for managing relational tables in Java applications. It is a specification and few implementations are like Hibernate, JDO, EJB, Toplink. By using JPA can be fetched data, insert, update etc.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 5. What is an Entity?

A class which should be persisted in a database it must be annotated with javax.persistence.EntitySuch a class is called Entity. 

An instances of the class will be a row in the person table. So, the columns in the person table will be mapped to the Person java object annotated as @Entity.
While insert, update or fetch record to or from the database we use entity as mapping with relational tables.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 6. What is the difference between persistence.xml and hibernate.cfg.xml?

When using JPA need persistence.xml and while using Hibernate API need hibernate.cfg.xml. When using JPA or Hibernate not needed both xmls, need the xml configuration file according to JPA or Hibernate.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 7. What is the difference between JPA and Hibernate?

Hibernate is one of the most popular open-source implementations of the latest specification (JPA 3.0). Even more likely the most popular, almost standard de facto.

That is, JPA only describes rules and APIs, and Hibernate implements these descriptions, however Hibernate (like many other JPA implementations) has additional features not described in JPA (and is not portable to other JPA implementations).

For solid differences, check JPA vs Hibernate.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 8. What are the two types of elements in Entity classes?

JPA indicates that it can work both with properties of classes (property), designed in the style of JavaBeans, or with fields (field), that is, class variables (instance variables). Accordingly, the type of access will be either property access or field access.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 9. What types of connections (relationships) between Entities?

There are four types of connections

  1. One-To-One: one-to-one connection, that is, one Entity object can be associated with no more than one object of another Entity
  2. One-To-Many: one-to-many connection, one Entity object can be associated with a whole collection of Entity
  3. Many-To-One: A relationship where one entity (column or set of columns) is/are referenced with another entity (column or set of columns) that contains unique values. In relational databases, these relations are applicable by using foreign key/primary key between tables.
  4. Many-To-Many: A relationship is a connection between two types of entities. In the case of a many-to-many relationship, both sides can relate to multiple instances of the other side. Note that it's possible for entity types to be in a relationship with themselves.

Bi-directional: A mapping is the most common way to model this relationship with JPA and Hibernate. It uses an attribute on the Order and the OrderItem entity. This allows you to navigate the association in both directions in your domain model and your JPQL queries.

Uni-directional: A mapping is an association between one persistence object and another one related persistence object. If one persistence object uses another and in back if other is not using the first persistence object then it becomes unidirectional.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 10. What is Persistent Fields?

  • If the entity class uses persistent fields, the Persistence runtime accesses entity-class instance variables directly.
  • All fields not annotated javax.persistence.Transient or not marked as Java transient will be persisted to the data store.
  • The object/relational mapping annotations must be applied to the instance variables.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 11. Is it possible to use JPA with NoSQL databases?

In general, the JPA specification says only about mapping java objects into relational database tables, but there are a number of implementations of this standard for NoSQL databases: Kundera, DataNucleus, ObjectDB, and a number of others. Naturally, not all specification-specific features for relational databases are transferred to NoSQL databases completely.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 12. What JPA requirements for Entity classes can you list?

1) Entity class must be annotated with Entity or described in the XML configuration file JPA,

2) Entity class must contain a public or protected constructor with no arguments (it can also have constructors with arguments),

3) Entity class must be a top-level class (top-level class),

4) Entity class cannot be an enum or interface,

5) Entity class cannot be the final class,

6) Entity class cannot contain final fields or methods if they participate in the mapping (persistent final methods or persistent final instance variables),

7) If an Entity class object is passed by value as a separate object (detached object), for example through a remote interface (through a remote interface), it must also implement a Serializable interface,

8) The Entity class fields should be directly accessible only to the methods of the Entity class and should not be directly accessible to other classes using this entity. Such classes should refer only to methods (getter/setter methods or other business logic methods in the Entity class),

9) The Entity class must contain a primary key, that is, an attribute or group of attributes that uniquely defines the record of this Entity class in the database.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 13. What is Persistent Properties?

  • If the entity uses persistent properties, the entity must follow the method conventions of JavaBeans components.
  • JavaBeans-style properties use getter and setter methods that are typically named after the entity class's instance variable names.
  • For every persistent property of type Type of the entity, there is a getter method getProperty and a setter method setProperty.
  • If the property is a Boolean, you may use isProperty instead of getProperty. For example, if a Customer entity uses persistent properties and has a private instance variable called firstName, the class defines a getFirstName and setFirstName method for retrieving and setting the state of the firstName instance variable.

    The method signature for single-valued persistent properties are as follows:

    Type getProperty()
    void setProperty(Type type)

    The object/relational mapping annotations for persistent properties must be applied to the getter methods. Mapping annotations cannot be applied to fields or properties annotated @Transient or marked transient.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 14. Explain Life Cycle of a JPA Entity.

Key states that an entity might be in:

  1. New / Transient: An object is instantiated but not yet associated with an Entity Manager and has no representation in the database.
  2. Managed / Persisted.
  3. Detached: Detached entity objects are objects in a special state in which they are not managed by any EntityManager but still represent objects in the database. Detached objects are often returned from a persistence tier to the web layer where they can be displayed to the end user in some form. Changes can be made to a detached object, but these changes won't be persisted in the database until the entity is reassociated with a persistence context (the entity is merged back to an EntityManager to become managed again).
  4. Removed.

    - The merge method's major task is to transfer the state from an unmanaged entity (passed as the argument) to its managed counterpart within the persistence context.
    - Merge deals with both new and detached entities. Merge causes either INSERT or UPDATE operation according to the sub-scenario (on the one hand it is more robust, on the other hand, this robustness needn't be required.)
    - Persist always causes INSERT SQL operation is executed (i.e. an exception may be thrown if the entity has already been inserted and thus the primary key violation happens.)

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 15. Insert a record mechanism using JPA. Provide an example.

@Override
@Transactional
public void create(Category entity) throws MeetingAppDAOException {
  try {
    logger.info("Enter - create()");
    super.create(entity);
    logger.info("Exit - create()");
  } catch (PersistenceException exception) {
    logger.error("create()::REASON OF EXCEPTION=" + exception.getMessage(), e);
  }
}

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 16. What is the attribute of the Entity class in JPA terminology?

JPA indicates that it can work both with properties of classes (property), designed in the style of JavaBeans, or with fields (field), that is, class variables (instance variables). Both types of elements of the Entity class are called attributes of the Entity class.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Intermediate / 1 to 5 years experienced level questions & answers

Ques 17. What is an EntityManager?

  • Entity manager javax.persistence.EntityManager provides the operations from and to the database, e.g. find objects, persists them, remove objects from the database, etc.
  • Entities which are managed by an EntityManager will automatically propagate these changes to the database (if this happens within a commit statement). These objects are known as persistent object. 
  • If the Entity Manager is closed (via close()) then the managed entities are in a detached stateThese are known as the detached objects. If you want synchronize them again with the database, the a Entity Manager provides the merge() method. Once merged, the object(s) becomes perstent objects again.
  • The EntityManager is the API of the persistence context, and an EntityManager can be injected directly in to a DAO without requiring a JPA Template. The Spring Container is capable of acting as a JPA container and of injecting the EntityManager by honoring the @PersistenceContext (both as field-level and a method-level annotation).

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 18. What is Embeddable classes?

  • Entities may use persistent fields, persistent properties, or a combination of both.
  • If the mapping annotations are applied to the entity's instance variables, the entity uses persistent fields.
  • If the mapping annotations are applied to the entity's getter methods for JavaBeans-style properties, the entity uses persistent properties.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 19. What data types are allowed in the attributes of the Entity class (fields or properties)?

Valid attribute types for Entity classes are:

  1. primitive types and their Java wrappers,
  2. strings,
  3. any Java serializable types,
  4. enums;
  5. entity types;
  6. embeddable classes
  7. collection types

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Experienced / Expert level questions & answers

Ques 20. What is JPQL?

JPQL (Java Persistence Query Language) offers an object-oriented syntax for expressing queries that are very similar to SQL. The language is interpreted at runtime, which means you cannot use the compiler to verify the correctness and integrity of a query. To address this limitation, Hibernate includes a Criteria API, which allows queries to be expressed programmatically.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 21. Example of an Entity with Embedded class.

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "categoryparticipant")
@NamedQueries({
@NamedQuery(name = "Categoryparticipant.getCategoriesOfParticipant", query = "SELECT cp.category from Categoryparticipant cp where cp.participant.participantid= :participantid")
})
public class Categoryparticipant implements Serializable {
private static final long serialVersionUID = 1L;
@EmbeddedId
protected CategoryparticipantPK categoryparticipantPK;
@Basic(optional = false)
@Column(name = "CreationDate")
@Temporal(TemporalType.TIMESTAMP)
private Date creationDate;
@JoinColumn(name = "ParticipantId", referencedColumnName = "ParticipantId", insertable = false, updatable = false)
@ManyToOne(optional = false)
private Participant participant;
@JoinColumn(name = "CategoryId", referencedColumnName = "CategoryId", insertable = false, updatable = false)
@ManyToOne(optional = false)
private Category category;

public Categoryparticipant() {
}

public Categoryparticipant(CategoryparticipantPK categoryparticipantPK) {
this.categoryparticipantPK = categoryparticipantPK;
}

public Categoryparticipant(CategoryparticipantPK categoryparticipantPK, Date creationDate) {
this.categoryparticipantPK = categoryparticipantPK;
this.creationDate = creationDate;
}

public Categoryparticipant(int categoryId, int participantId) {
this.categoryparticipantPK = new CategoryparticipantPK(categoryId, participantId);
}

public CategoryparticipantPK getCategoryparticipantPK() {
return categoryparticipantPK;
}

public void setCategoryparticipantPK(CategoryparticipantPK categoryparticipantPK) {
this.categoryparticipantPK = categoryparticipantPK;
}

public Date getCreationDate() {
return creationDate;
}

public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
}

public Participant getParticipant() {
return participant;
}

public void setParticipant(Participant participant) {
this.participant = participant;
}

public Category getCategory() {
return category;
}

public void setCategory(Category category) {
this.category = category;
}

@Override
public int hashCode() {
int hash = 0;
hash += (categoryparticipantPK != null ? categoryparticipantPK.hashCode() : 0);
return hash;
}

@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Categoryparticipant)) {
return false;
}
Categoryparticipant other = (Categoryparticipant) object;
if ((this.categoryparticipantPK == null && other.categoryparticipantPK != null) || (this.categoryparticipantPK != null && !this.categoryparticipantPK.equals(other.categoryparticipantPK))) {
return false;
}
return true;
}

@Override
public String toString() {
return "com.xchanging.entity.jpa.Categoryparticipant[categoryparticipantPK=" + categoryparticipantPK + "]";
}

}

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 22. Give an example of Embeddable class for previous question Categoryparticipant entity.

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;

@Embeddable
public class CategoryparticipantPK implements Serializable {
@Basic(optional = false)
@Column(name = "CategoryId")
private int categoryId;
@Basic(optional = false)
@Column(name = "ParticipantId")
private int participantId;

public CategoryparticipantPK() {
}

public CategoryparticipantPK(int categoryId, int participantId) {
this.categoryId = categoryId;
this.participantId = participantId;
}

public int getCategoryId() {
return categoryId;
}

public void setCategoryId(int categoryId) {
this.categoryId = categoryId;
}

public int getParticipantId() {
return participantId;
}

public void setParticipantId(int participantId) {
this.participantId = participantId;
}

@Override
public int hashCode() {
int hash = 0;
hash += (int) categoryId;
hash += (int) participantId;
return hash;
}

@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof CategoryparticipantPK)) {
return false;
}
CategoryparticipantPK other = (CategoryparticipantPK) object;
if (this.categoryId != other.categoryId) {
return false;
}
if (this.participantId != other.participantId) {
return false;
}
return true;
}

@Override
public String toString() {
return "com.xchanging.entity.jpa.CategoryparticipantPK[categoryId=" + categoryId + ", participantId=" + participantId + "]";
}

}

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 23. How to fetch a record using NamedQuery?

public Category findByCategoryId(Long categoryId) {
try {
logger.info("Enter - findByCategoryId()");
Query lQuery = (Query) em.createNamedQuery("Category.findByCategoryId");
Integer intValue = categoryId.intValue();
lQuery.setParameter("categoryId", intValue);
Category category = (Category) lQuery.getSingleResult();
logger.info("Exit - findByCategoryId");
return category;
} catch (PersistenceException exception) {
logger.debug(exception.getCause().getStackTrace());
logger.error("CategoryDaoImpl::maxCategoryId()::REASON OF EXCEPTION=" + exception.getMessage() + exception.getCause());
} finally {
closeEntityManager();
}

}

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 24. What is the difference between JPA and JDO?

JPA (Java Persistence API) and Java Data Objects (JDO) are two specifications for storing java objects in databases.

If JPA is concentrated only on relational databases, then JDO is a more general specification that describes the ORM for any possible bases and repositories.

In principle, JPA can be viewed as part of the JDO specification specialized in relational databases, even though the API of these two specifications does not completely match.

The “developers” of specifications also differ – if JPA is developed as JSR, then JDO was first developed as JSR, and now it is developed as an Apache JDO project.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 25. What requirements does JPA set for Embeddable classes?

  1. Such classes must satisfy the same rules as the Entity classes, except that they do not have to contain a primary key and be marked with the Entity annotation.
  2. The Embeddable class must be marked with the Embeddable annotation or described in the XML configuration file JPA.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 26. What is a Mapped Superclass?

A mapped Superclass is a class from which Entity is inherited, it may contain JPA annotations, however, such a class is not Entity, it does not have to fulfill all the requirements set for Entity (for example, it may not contain a primary key).

Such a class cannot be used in EntityManager or Query operations. Such a class should be marked with the MappedSuperclass annotation or, respectively, described in the XML file.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 27. On each of the four statuses of Entity objects, how are the operations persisted?

  • For the new status, the object will get saved to the database after a transaction is committed and changes to the status managed.
  • If the status is managed, it ignores the operation. But the status of the dependent Entity can be changed to 'managed' if the cascading annotations are there.
  • For the removed status, it changes to managed thereafter.
  • For the detached status, it throws the exception at the transaction's commit stage or right away.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 28. What are the effects on the statuses of Entity objects of the merge operation?

  • For the new status, a new managed entity is created, and the past data will be copied into it.
  • For the managed status, it ignores the operation, but it works on the Entity dependent on cascading when the status is not managed.
  • For the removed status, it throws the exception at the transaction's commit stage or right away.
  • For the detached status, it either creates a new managed with the data copied or copies the data to the existing managed Entity

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 29. What are the effects on the statuses of Entity objects of the remove operation?

  • For the new status, it ignores the operation, but the status changes to removed on the Entity dependent on cascading. Here the status shouldn't be managed.
  • For the managed status, the status changes to removed thereafter, and the removed database records the object during the commit stage.
  • For the removed status, it ignores the operation.
  • For the detached status, it throws the exception at the transaction's commit stage or right away.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 30. What are the effects on the statuses of Entity objects of the detach operation?

  • For the new or detached status, it ignores the operation.
  • For the managed or removed status, the Entity's status and also of the objects dependent on cascade become detached.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 31. What are the effects on the statuses of Entity objects of the refresh operation?

  • For the new, detached, or removed status, it throws out the exception.
  • For the managed status, it restores all the changes from the database and refreshes all objects dependent on the cascade.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 32. Mention the types of cache in JPA and their use.

There are two types of cache in JPA:

  • First-level cache: Data is cached from a single transaction.
  • Second-level transaction: Data is cached from more than one transaction.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 33. What is the purpose of access annotation?

The access type for an entity class, embeddable, superclass, or individual attributes is defined by it. This defines the way JPA refers to entity attributes such as class properties or class fields having setters and getters.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 34. What is the purpose of Basic annotation?

The simplest type of mapping of data on a column of the database is indicated by the basic annotation.

Also, the fetch field access strategy, as well as the requirement of the field, can be specified in the annotation parameters.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 35. List the six types of locks available in JPA specification in ascending order.

The six types of locks are listed below in the ascending order of their reliability:

  • NONE
  • OPTIMISTIC
  • OPTIMISTIC_FORCE_INCREMENT
  • PESSIMISTIC_READ
  • PESSIMISTIC_WRITE
  • PESSIMISTICI

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 36. What options does JPA provide to set a second-level cache, or what values can be taken from the persistence.xml by the shared-cache-mode element?

The following five options are there:

  • ALL
  • NONE
  • ENABLE_SELECTIVE
  • DISABLE_SELECTIVE
  • UNSPECIFIED

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 37. How can the JPA metadata that is the information about entity type, embeddable class, etc., be obtained?

The Metamodel interface is used by JPA for this purpose.

We can obtain this interface's object using the method of getMetamodel from an EntityManger or EntityMangerFactory.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 38. What is a unique inheritance strategy not present in the JPA specification but present in Hibernate?

The implicit polymorphism strategy is present in Hibernate but it is not present in JPA.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 39. What do you mean by JPQL (Java Persistence query language), and how does it differ from SQL?

  • JPQL is almost similar to SQL, but the names of entity classes and attributes are used instead of the database columns.
  • Also, the data types of entity attributes are used by the query parameters instead of database fields.
  • There is automatic polymorphism in JPQL, unlike SQL. KEY, TREAT, VALUE, MAP, and ENTRY are some of the unique functions of JPQL.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 40. What is polymorphism in JPQL queries?

This means that regardless of the inheritance strategy, the objects of all the descendant classes are returned in each entity request.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Ques 41. How can the polymorphism be turned off in JPQL?

We can use the TYPE function in the where condition for turning polymorphism off in JPQL.

Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

Verwandte Vergleiche

JDBC vs JPAJPA vs Hibernate

Related interview subjects

Java Applet interviewfragen und antworten - Total 29 questions
Java Mail interviewfragen und antworten - Total 27 questions
Google Gson interviewfragen und antworten - Total 8 questions
Java 21 interviewfragen und antworten - Total 21 questions
RMI interviewfragen und antworten - Total 31 questions
Java Support interviewfragen und antworten - Total 30 questions
Apache Camel interviewfragen und antworten - Total 20 questions
Struts interviewfragen und antworten - Total 84 questions
JAXB interviewfragen und antworten - Total 18 questions
J2EE interviewfragen und antworten - Total 25 questions
JUnit interviewfragen und antworten - Total 24 questions
Java OOPs interviewfragen und antworten - Total 30 questions
Apache Tapestry interviewfragen und antworten - Total 9 questions
JSP interviewfragen und antworten - Total 49 questions
Java Concurrency interviewfragen und antworten - Total 30 questions
JDBC interviewfragen und antworten - Total 27 questions
Java 11 interviewfragen und antworten - Total 24 questions
Java Garbage Collection interviewfragen und antworten - Total 30 questions
Java Swing interviewfragen und antworten - Total 27 questions
Java Design Patterns interviewfragen und antworten - Total 15 questions
Spring Framework interviewfragen und antworten - Total 53 questions
JPA interviewfragen und antworten - Total 41 questions
JSF interviewfragen und antworten - Total 24 questions
Java 8 interviewfragen und antworten - Total 30 questions
Hibernate interviewfragen und antworten - Total 52 questions
JMS interviewfragen und antworten - Total 64 questions
Java 17 interviewfragen und antworten - Total 20 questions
Java Beans interviewfragen und antworten - Total 57 questions
Java Exception Handling interviewfragen und antworten - Total 30 questions
Spring Boot interviewfragen und antworten - Total 50 questions
Servlets interviewfragen und antworten - Total 34 questions
Kotlin interviewfragen und antworten - Total 30 questions
EJB interviewfragen und antworten - Total 80 questions
Java 15 interviewfragen und antworten - Total 16 questions
Java Multithreading interviewfragen und antworten - Total 30 questions
Apache Wicket interviewfragen und antworten - Total 26 questions
Core Java interviewfragen und antworten - Total 306 questions
JBoss interviewfragen und antworten - Total 14 questions
Log4j interviewfragen und antworten - Total 35 questions

All interview subjects

C# interviewfragen und antworten - Total 41 questions
LINQ interviewfragen und antworten - Total 20 questions
ASP .NET interviewfragen und antworten - Total 31 questions
Microsoft .NET interviewfragen und antworten - Total 60 questions
ASP interviewfragen und antworten - Total 82 questions
IBM Watson interviewfragen und antworten - Total 30 questions
Perplexity AI interviewfragen und antworten - Total 40 questions
ChatGPT interviewfragen und antworten - Total 20 questions
NLP interviewfragen und antworten - Total 30 questions
AI Agents (Agentic AI) interviewfragen und antworten - Total 50 questions
OpenCV interviewfragen und antworten - Total 36 questions
Amazon SageMaker interviewfragen und antworten - Total 30 questions
TensorFlow interviewfragen und antworten - Total 30 questions
Hugging Face interviewfragen und antworten - Total 30 questions
Gemini AI interviewfragen und antworten - Total 50 questions
Artificial Intelligence (AI) interviewfragen und antworten - Total 47 questions
Oracle AI Agents interviewfragen und antworten - Total 50 questions
Machine Learning interviewfragen und antworten - Total 30 questions
Google Cloud AI interviewfragen und antworten - Total 30 questions
Scala interviewfragen und antworten - Total 48 questions
Swift interviewfragen und antworten - Total 49 questions
Golang interviewfragen und antworten - Total 30 questions
Embedded C interviewfragen und antworten - Total 30 questions
VBA interviewfragen und antworten - Total 30 questions
C++ interviewfragen und antworten - Total 142 questions
COBOL interviewfragen und antworten - Total 50 questions
R Language interviewfragen und antworten - Total 30 questions
Python Coding interviewfragen und antworten - Total 20 questions
CCNA interviewfragen und antworten - Total 40 questions
Oracle Cloud Infrastructure (OCI) interviewfragen und antworten - Total 100 questions
AWS interviewfragen und antworten - Total 87 questions
Azure Data Factory interviewfragen und antworten - Total 30 questions
Microsoft Azure interviewfragen und antworten - Total 35 questions
OpenStack interviewfragen und antworten - Total 30 questions
ServiceNow interviewfragen und antworten - Total 30 questions
Snowflake interviewfragen und antworten - Total 30 questions
Oracle APEX interviewfragen und antworten - Total 23 questions
PDPA interviewfragen und antworten - Total 20 questions
OSHA interviewfragen und antworten - Total 20 questions
HIPPA interviewfragen und antworten - Total 20 questions
PHIPA interviewfragen und antworten - Total 20 questions
FERPA interviewfragen und antworten - Total 20 questions
DPDP interviewfragen und antworten - Total 30 questions
PIPEDA interviewfragen und antworten - Total 20 questions
CCPA interviewfragen und antworten - Total 20 questions
GDPR interviewfragen und antworten - Total 30 questions
HITRUST interviewfragen und antworten - Total 20 questions
LGPD interviewfragen und antworten - Total 20 questions
Data Structures interviewfragen und antworten - Total 49 questions
Computer Networking interviewfragen und antworten - Total 65 questions
Microsoft Excel interviewfragen und antworten - Total 37 questions
Computer Basics interviewfragen und antworten - Total 62 questions
Computer Science interviewfragen und antworten - Total 50 questions
MS Word interviewfragen und antworten - Total 50 questions
Operating System interviewfragen und antworten - Total 22 questions
Tips and Tricks interviewfragen und antworten - Total 30 questions
PoowerPoint interviewfragen und antworten - Total 50 questions
Pandas interviewfragen und antworten - Total 30 questions
Deep Learning interviewfragen und antworten - Total 29 questions
PySpark interviewfragen und antworten - Total 30 questions
Flask interviewfragen und antworten - Total 40 questions
PyTorch interviewfragen und antworten - Total 25 questions
Data Science interviewfragen und antworten - Total 23 questions
SciPy interviewfragen und antworten - Total 30 questions
Generative AI interviewfragen und antworten - Total 30 questions
NumPy interviewfragen und antworten - Total 30 questions
Python interviewfragen und antworten - Total 106 questions
Python Pandas interviewfragen und antworten - Total 48 questions
Python Matplotlib interviewfragen und antworten - Total 30 questions
Django interviewfragen und antworten - Total 50 questions
MariaDB interviewfragen und antworten - Total 40 questions
DBMS interviewfragen und antworten - Total 73 questions
Apache Hive interviewfragen und antworten - Total 30 questions
SSIS interviewfragen und antworten - Total 30 questions
PostgreSQL interviewfragen und antworten - Total 30 questions
Teradata interviewfragen und antworten - Total 20 questions
SQL Query interviewfragen und antworten - Total 70 questions
SQLite interviewfragen und antworten - Total 53 questions
Cassandra interviewfragen und antworten - Total 25 questions
Neo4j interviewfragen und antworten - Total 44 questions
MSSQL interviewfragen und antworten - Total 50 questions
OrientDB interviewfragen und antworten - Total 46 questions
SQL interviewfragen und antworten - Total 152 questions
Data Warehouse interviewfragen und antworten - Total 20 questions
IBM DB2 interviewfragen und antworten - Total 40 questions
Data Mining interviewfragen und antworten - Total 30 questions
Elasticsearch interviewfragen und antworten - Total 61 questions
Oracle interviewfragen und antworten - Total 34 questions
MongoDB interviewfragen und antworten - Total 27 questions
AWS DynamoDB interviewfragen und antworten - Total 46 questions
Entity Framework interviewfragen und antworten - Total 46 questions
MySQL interviewfragen und antworten - Total 108 questions
Data Modeling interviewfragen und antworten - Total 30 questions
Redis Cache interviewfragen und antworten - Total 20 questions
Data Engineer interviewfragen und antworten - Total 30 questions
Robotics interviewfragen und antworten - Total 28 questions
AutoCAD interviewfragen und antworten - Total 30 questions
Power System interviewfragen und antworten - Total 28 questions
Electrical Engineering interviewfragen und antworten - Total 30 questions
Verilog interviewfragen und antworten - Total 30 questions
Digital Electronics interviewfragen und antworten - Total 38 questions
VLSI interviewfragen und antworten - Total 30 questions
Software Engineering interviewfragen und antworten - Total 27 questions
MATLAB interviewfragen und antworten - Total 25 questions
Civil Engineering interviewfragen und antworten - Total 30 questions
Electrical Machines interviewfragen und antworten - Total 29 questions
Oracle CXUnity interviewfragen und antworten - Total 29 questions
Web Services interviewfragen und antworten - Total 10 questions
Salesforce Lightning interviewfragen und antworten - Total 30 questions
IBM Integration Bus interviewfragen und antworten - Total 30 questions
Power BI interviewfragen und antworten - Total 24 questions
OIC interviewfragen und antworten - Total 30 questions
Web API interviewfragen und antworten - Total 31 questions
Dell Boomi interviewfragen und antworten - Total 30 questions
Salesforce interviewfragen und antworten - Total 57 questions
IBM DataStage interviewfragen und antworten - Total 20 questions
Talend interviewfragen und antworten - Total 34 questions
TIBCO interviewfragen und antworten - Total 30 questions
Informatica interviewfragen und antworten - Total 48 questions
Java Applet interviewfragen und antworten - Total 29 questions
Java Mail interviewfragen und antworten - Total 27 questions
Google Gson interviewfragen und antworten - Total 8 questions
Java 21 interviewfragen und antworten - Total 21 questions
RMI interviewfragen und antworten - Total 31 questions
Java Support interviewfragen und antworten - Total 30 questions
Apache Camel interviewfragen und antworten - Total 20 questions
Struts interviewfragen und antworten - Total 84 questions
JAXB interviewfragen und antworten - Total 18 questions
J2EE interviewfragen und antworten - Total 25 questions
JUnit interviewfragen und antworten - Total 24 questions
Java OOPs interviewfragen und antworten - Total 30 questions
Apache Tapestry interviewfragen und antworten - Total 9 questions
JSP interviewfragen und antworten - Total 49 questions
Java Concurrency interviewfragen und antworten - Total 30 questions
JDBC interviewfragen und antworten - Total 27 questions
Java 11 interviewfragen und antworten - Total 24 questions
Java Garbage Collection interviewfragen und antworten - Total 30 questions
Java Swing interviewfragen und antworten - Total 27 questions
Java Design Patterns interviewfragen und antworten - Total 15 questions
Spring Framework interviewfragen und antworten - Total 53 questions
JPA interviewfragen und antworten - Total 41 questions
JSF interviewfragen und antworten - Total 24 questions
Java 8 interviewfragen und antworten - Total 30 questions
Hibernate interviewfragen und antworten - Total 52 questions
JMS interviewfragen und antworten - Total 64 questions
Java 17 interviewfragen und antworten - Total 20 questions
Java Beans interviewfragen und antworten - Total 57 questions
Java Exception Handling interviewfragen und antworten - Total 30 questions
Spring Boot interviewfragen und antworten - Total 50 questions
Servlets interviewfragen und antworten - Total 34 questions
Kotlin interviewfragen und antworten - Total 30 questions
EJB interviewfragen und antworten - Total 80 questions
Java 15 interviewfragen und antworten - Total 16 questions
Java Multithreading interviewfragen und antworten - Total 30 questions
Apache Wicket interviewfragen und antworten - Total 26 questions
Core Java interviewfragen und antworten - Total 306 questions
JBoss interviewfragen und antworten - Total 14 questions
Log4j interviewfragen und antworten - Total 35 questions
ITIL interviewfragen und antworten - Total 25 questions
Finance interviewfragen und antworten - Total 30 questions
JIRA interviewfragen und antworten - Total 30 questions
SAP MM interviewfragen und antworten - Total 30 questions
SAP ABAP interviewfragen und antworten - Total 24 questions
SCCM interviewfragen und antworten - Total 30 questions
Tally interviewfragen und antworten - Total 30 questions
Pega interviewfragen und antworten - Total 30 questions
Android interviewfragen und antworten - Total 14 questions
Mobile Computing interviewfragen und antworten - Total 20 questions
Xamarin interviewfragen und antworten - Total 31 questions
iOS interviewfragen und antworten - Total 52 questions
Ionic interviewfragen und antworten - Total 32 questions
Kubernetes interviewfragen und antworten - Total 30 questions
Microservices interviewfragen und antworten - Total 30 questions
Apache Kafka interviewfragen und antworten - Total 38 questions
Tableau interviewfragen und antworten - Total 20 questions
Adobe AEM interviewfragen und antworten - Total 50 questions
IAS interviewfragen und antworten - Total 56 questions
PHP OOPs interviewfragen und antworten - Total 30 questions
OOPs interviewfragen und antworten - Total 30 questions
Fashion Designer interviewfragen und antworten - Total 20 questions
Desktop Support interviewfragen und antworten - Total 30 questions
CICS interviewfragen und antworten - Total 30 questions
Yoga Teachers Training interviewfragen und antworten - Total 30 questions
Nursing interviewfragen und antworten - Total 40 questions
Linked List interviewfragen und antworten - Total 15 questions
Dynamic Programming interviewfragen und antworten - Total 30 questions
SharePoint interviewfragen und antworten - Total 28 questions
Behavioral interviewfragen und antworten - Total 29 questions
School Teachers interviewfragen und antworten - Total 25 questions
Language in C interviewfragen und antworten - Total 80 questions
Statistics interviewfragen und antworten - Total 30 questions
Digital Marketing interviewfragen und antworten - Total 40 questions
Apache Spark interviewfragen und antworten - Total 24 questions
Full-Stack Developer interviewfragen und antworten - Total 60 questions
IIS interviewfragen und antworten - Total 30 questions
System Design interviewfragen und antworten - Total 30 questions
VISA interviewfragen und antworten - Total 30 questions
Google Analytics interviewfragen und antworten - Total 30 questions
Cloud Computing interviewfragen und antworten - Total 42 questions
BPO interviewfragen und antworten - Total 48 questions
ANT interviewfragen und antworten - Total 10 questions
SEO interviewfragen und antworten - Total 51 questions
SAS interviewfragen und antworten - Total 24 questions
Control System interviewfragen und antworten - Total 28 questions
Agile Methodology interviewfragen und antworten - Total 30 questions
HR Questions interviewfragen und antworten - Total 49 questions
REST API interviewfragen und antworten - Total 52 questions
Content Writer interviewfragen und antworten - Total 30 questions
Banking interviewfragen und antworten - Total 20 questions
Checkpoint interviewfragen und antworten - Total 20 questions
Blockchain interviewfragen und antworten - Total 29 questions
Technical Support interviewfragen und antworten - Total 30 questions
Mainframe interviewfragen und antworten - Total 20 questions
Hadoop interviewfragen und antworten - Total 40 questions
Chemistry interviewfragen und antworten - Total 50 questions
Docker interviewfragen und antworten - Total 30 questions
Sales interviewfragen und antworten - Total 30 questions
Nature interviewfragen und antworten - Total 20 questions
Interview Tips interviewfragen und antworten - Total 30 questions
College Teachers interviewfragen und antworten - Total 30 questions
SDLC interviewfragen und antworten - Total 75 questions
Cryptography interviewfragen und antworten - Total 40 questions
RPA interviewfragen und antworten - Total 26 questions
Blue Prism interviewfragen und antworten - Total 20 questions
Memcached interviewfragen und antworten - Total 28 questions
GIT interviewfragen und antworten - Total 30 questions
DevOps interviewfragen und antworten - Total 45 questions
Accounting interviewfragen und antworten - Total 30 questions
SSB interviewfragen und antworten - Total 30 questions
Algorithm interviewfragen und antworten - Total 50 questions
Business Analyst interviewfragen und antworten - Total 40 questions
Splunk interviewfragen und antworten - Total 30 questions
Sqoop interviewfragen und antworten - Total 30 questions
JSON interviewfragen und antworten - Total 16 questions
OSPF interviewfragen und antworten - Total 30 questions
Insurance interviewfragen und antworten - Total 30 questions
Scrum Master interviewfragen und antworten - Total 30 questions
Accounts Payable interviewfragen und antworten - Total 30 questions
Computer Graphics interviewfragen und antworten - Total 25 questions
IoT interviewfragen und antworten - Total 30 questions
Bitcoin interviewfragen und antworten - Total 30 questions
Active Directory interviewfragen und antworten - Total 30 questions
Laravel interviewfragen und antworten - Total 30 questions
XML interviewfragen und antworten - Total 25 questions
GraphQL interviewfragen und antworten - Total 32 questions
Ansible interviewfragen und antworten - Total 30 questions
Electron.js interviewfragen und antworten - Total 24 questions
ES6 interviewfragen und antworten - Total 30 questions
RxJS interviewfragen und antworten - Total 29 questions
NodeJS interviewfragen und antworten - Total 30 questions
Vue.js interviewfragen und antworten - Total 30 questions
ExtJS interviewfragen und antworten - Total 50 questions
jQuery interviewfragen und antworten - Total 22 questions
Svelte.js interviewfragen und antworten - Total 30 questions
Shell Scripting interviewfragen und antworten - Total 50 questions
Next.js interviewfragen und antworten - Total 30 questions
Knockout JS interviewfragen und antworten - Total 25 questions
TypeScript interviewfragen und antworten - Total 38 questions
PowerShell interviewfragen und antworten - Total 27 questions
Terraform interviewfragen und antworten - Total 30 questions
JCL interviewfragen und antworten - Total 20 questions
JavaScript interviewfragen und antworten - Total 59 questions
Ajax interviewfragen und antworten - Total 58 questions
Express.js interviewfragen und antworten - Total 30 questions
Ethical Hacking interviewfragen und antworten - Total 40 questions
Cyber Security interviewfragen und antworten - Total 50 questions
PII interviewfragen und antworten - Total 30 questions
Data Protection Act interviewfragen und antworten - Total 20 questions
BGP interviewfragen und antworten - Total 30 questions
Ubuntu interviewfragen und antworten - Total 30 questions
Linux interviewfragen und antworten - Total 43 questions
Unix interviewfragen und antworten - Total 105 questions
Weblogic interviewfragen und antworten - Total 30 questions
Tomcat interviewfragen und antworten - Total 16 questions
Glassfish interviewfragen und antworten - Total 8 questions
TestNG interviewfragen und antworten - Total 38 questions
Postman interviewfragen und antworten - Total 30 questions
SDET interviewfragen und antworten - Total 30 questions
UiPath interviewfragen und antworten - Total 38 questions
Quality Assurance interviewfragen und antworten - Total 56 questions
Selenium interviewfragen und antworten - Total 40 questions
Kali Linux interviewfragen und antworten - Total 29 questions
Mobile Testing interviewfragen und antworten - Total 30 questions
API Testing interviewfragen und antworten - Total 30 questions
Appium interviewfragen und antworten - Total 30 questions
ETL Testing interviewfragen und antworten - Total 20 questions
QTP interviewfragen und antworten - Total 44 questions
Cucumber interviewfragen und antworten - Total 30 questions
PHP interviewfragen und antworten - Total 27 questions
Oracle JET(OJET) interviewfragen und antworten - Total 54 questions
Frontend Developer interviewfragen und antworten - Total 30 questions
Zend Framework interviewfragen und antworten - Total 24 questions
RichFaces interviewfragen und antworten - Total 26 questions
HTML interviewfragen und antworten - Total 27 questions
Flutter interviewfragen und antworten - Total 25 questions
CakePHP interviewfragen und antworten - Total 30 questions
React interviewfragen und antworten - Total 40 questions
React Native interviewfragen und antworten - Total 26 questions
Angular JS interviewfragen und antworten - Total 21 questions
Web Developer interviewfragen und antworten - Total 50 questions
Angular 8 interviewfragen und antworten - Total 32 questions
Dojo interviewfragen und antworten - Total 23 questions
GWT interviewfragen und antworten - Total 27 questions
Symfony interviewfragen und antworten - Total 30 questions
Ruby On Rails interviewfragen und antworten - Total 74 questions
CSS interviewfragen und antworten - Total 74 questions
Yii interviewfragen und antworten - Total 30 questions
Angular interviewfragen und antworten - Total 50 questions
Copyright © 2026, WithoutBook.