Found 2616 Articles for Java

How To Calculate Volume of Prism in Java?

Mr. Satyabrata
Updated on 27-Oct-2022 09:13:10

662 Views

A prism refers to a three−dimensional solid object which has two identical ends. A prism has 2 faces, the first one top and bottom face and second one is lateral faces. Both top and bottom faces are called bases which are identical to each other. All lateral faces are also identical to each other which belong to the class of parallelograms. When the base of the prism is triangular in shape that prism is called a triangular prism. Similarly, when the base of a prism is rectangular in shape it is called a rectangular prism. Other types of prisms are ... Read More

What are various Inheritance mapping strategies available in Hibernate?

Manu
Updated on 26-Aug-2022 11:47:53

768 Views

There are three types of inheritance mapping strategies − Table per class hierarchy Table per concrete class Table per subclassIn this article, we will discuss table per class hierarchy. Table per class hierarchy In this, only a single table is created for inheritance mapping. Disadvantages of this approach is that a lot of null values gets stored in the table. @Inheritance(strategy=InheritanceType.SINGLE_TABLE), @DiscriminatorColumn and @DiscriminatorValue are the annotations used in this strategy. @DiscriminatorColumn is used to create an additional column which is used to identify the hierarchy classes. Consider the following example to understand this − Steps ... Read More

How to Execute Batch Insert Update in Hibernate?

Manu
Updated on 26-Aug-2022 11:40:06

3K+ Views

In this article, we will see how we can execute batch insert/update in hibernate. Whenever we execute a sql statement, we do it by making a network call to the database. Now, if we have to insert 10 entries to our database table, then we have to make 10 network calls. Instead we can optimize our network calls by using batching. Batching allows us to execute a group of SQL statements in a single network call. To understand and implement this, let us define our entities − @Entity public class Parent { @Id @GeneratedValue(strategy ... Read More

How to customize the Result of JPA Queries with Aggregation Functions?

Manu
Updated on 26-Aug-2022 11:34:40

2K+ Views

Most of the time when we use JPA queries, the result obtained is mapped to an object/particular data type. But When we use aggregate function in queries, handling the result sometimes require us to customize our JPA query. Let’s understand this with help of an example (Department, Employee) − Dept.java @Entity public class Dept { @Id private Long id; private String name; @OneToMany(mappedBy = "dep") private List emp; //Getters //Setters } A department can have one or more ... Read More

How does Hibernate Second Level Cache Works?

Manu
Updated on 26-Aug-2022 11:24:31

2K+ Views

Caching helps to reduce database network call, for executing queries. First level cache is linked with a session. It is implemented implicitly. First level cache exist only till the session object is there. Once session object is terminated/closed, there will be no cache objects. Second level cache works across multiple sessions objects. It is linked with a session factory. Second level cache objects are available to all the session in a single session factory. These cache objects are terminated when that particular session factory is closed. Implementing second level caching We need to add the following dependencies in order to ... Read More

Different methods to append a single character to a string or char array in Java

Janani Jaganathan
Updated on 25-Aug-2022 09:06:21

671 Views

Have you ever faced the situation of extending a string or char array? If you haven't yet, you might probably encounter this situation in the future. It is a common practice to append a single character to a string or char array in Java. The significant difference between a string array and a char array is that a string array is a sequence of characters, and a char array is a sequence of collection of data type char. String array runs as a single entity, whereas char array runs as a separate entity. In this blog, we will look ... Read More

Top Resources for Java Interview Questions

Janani Jaganathan
Updated on 25-Aug-2022 09:06:56

284 Views

Are you a fresher or final-year graduate looking to start your career as a Java developer? Have you already landed as a java developer and are looking to prepare for the next company? If you say "Yes" to any of these questions, then you are at the right place. In this article, you will come across the top resources and websites that will help you to prepare and do well in java programming interviews. The list includes popular online platforms and websites like Tutorialspoint, StackOverflow, DZone, etc., where you can learn frequently asked java questions in top companies' interviews and ... Read More

Difference between Groovy and Java

Pradeep Kumar
Updated on 25-Jul-2022 09:37:54

736 Views

Programmers have been using scripting languages for quite some time. When it comes to Linux and Unix computers, scripting languages were mostly utilised for things like scripting tasks that automate platform customizations, software installations, and one-shot command line jobs with bash scripts.Server-side scripting languages like PHP have been increasingly popular for use in the development of high-traffic websites. Server-side scripting languages are also the most appropriate choice for use in critical business applications. Scripting languages are generally not dependent on any one platform, nor do they typically communicate with one another. On the other hand, the integration is not always ... Read More

How to use List size() method in Java With Examples?

Mahesh Parahar
Updated on 27-May-2022 08:33:11

425 Views

The List interface extends the Collection interface and stores a sequence of elements. The List interface provides two methods to efficiently insert and remove multiple elements at an arbitrary point in the list. Unlike sets, list allows duplicate elements, and allows multiple null values if null value is allowed in the list.List interface size() can be used to get the count of elements currently present in the list. It always returns the count of currently present elements. You can check the latest size after adding/removing element(s) to the list.Syntaxint size()NotesReturns the number of elements in this list.If this list contains ... Read More

How to get sublist of List in Java?

Mahesh Parahar
Updated on 26-May-2022 13:25:38

6K+ Views

The List interface extends Collection and declares the behavior of a collection that stores a sequence of elements. User of a list has quite precise control over where an element to be inserted in the List. These elements are accessible by their index and are searchable. ArrayList is the most popular implementation of the List interface.List interface method subList() can be used to get a sublist of the list. It requires start and end index. This sublist contains the same objects as in original list and changes to sublist will also reflect in original list. In this article, we're discussing ... Read More

Advertisements