S
S
Sergey Rolich2011-10-20 08:11:34
Java
Sergey Rolich, 2011-10-20 08:11:34

What is the best way to implement entity in java?

I am new to JavaEE and I have this question. There are several tables that are interconnected 1 to 1.
What is the best way to implement work with data: create an entity for each table and then create a class in which to use all these entities, or create a complex entity using @SecondaryTables annotations. Desirable pros and cons of both methods. Thanks in advance.

PS EclipseLink is used as persistence provider

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
SergeyGrigorev, 2011-10-20
@SergeyGrigorev

Performance is extremely important in our product, because huge amounts of data are processed. Therefore, we use Entity for each table, then they are transferred to separate DAO objects that implement the logic of object binding, with preliminary data quality checks, etc., as well as the ability to load data incompletely. In this case, some of the data, such as special keys that identify records or relationships, are loaded through jdbc, and not through Entity.

P
png, 2011-10-20
@png

plus JDBC - performance, you can make complex queries and more.
minus - you have to write with pens more. All the same, the data will need to be placed by objects, not by arrays to store them.
if your queries are simple, then JPA will help you save time and code. It's comfortable. But sometimes to the detriment of speed and flexibility.
It is also worth thinking about how to insert data. what is their volume? how many threads will read/write?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question