T
T
TestProj2016-08-02 16:56:28
Java
TestProj, 2016-08-02 16:56:28

Is there an equivalent of lookup fields in hibernate/java ORM?

Good time of the day! It is required to rewrite a delphi application in java using swing (it is it, not fx).
While writing, studying and everything else, there were problems and questions related to the operation of the database. The fact is that in Delphi it was possible to use lookup fields (to display the value), but how to deal with this in java is not clear. Writing native queries to the database is also not an option. Too bulky tables, everything is interconnected, something always refers to something. I want to make my life easier.
Questions:

  1. Using hibernate, is it possible to do something similar? (a la lookup fields)
  2. Are there any tools or tools that will make all this a little bit easier.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Kosarev, 2016-08-02
@jaxtr

If a lookup field means a related entity, then see the @ManyToOne or @OneToOne annotations. Something like:

@Entity 
public class City {
    private String name;
}

@Entity 
public class Person {
    @ManyToOne
    private City city;
}

// и где-то:
person.getCity().getName();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question