Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

359
Views
¿Hibernate retrocede la referencia en la relación @OneToMany @ManyToOne automáticamente?

Tengo una entidad de pedido que tiene orderItems lista de artículos de pedido.

 @OneToMany(mappedBy ="order") List<OrderItem> orderItems;

OrderItem tiene una referencia posterior a Order

 @ManyToOne Order order;

Cuando guardo el Order , ¿debo configurar manualmente la referencia inversa en la entidad OrderItem ? Me gusta esto

 OrderItem orderItem1 = new OrderItem( //constructor ); OrderItem orderItem2 = new OrderItem( //constructor ); List orderItems = Arrays.asList(orderItem1, orderItem2); Order order = new Order( orderItems); orderItems.forEach(orderItem -> orderItem.setOrder(order); // like this?

¿Hibernate y Spring data jpa lo configuran automáticamente?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Para crear y actualizar el caso, no lo ayudarán a configurarlo automáticamente y debe configurar la relación usted mismo.

mappedBy aquí es para definir si Order.orderItems o OrderItem.order se usarán para proporcionar el valor para la columna DB correspondiente que se vincula entre ellos. (es decir, la columna order_id en la tabla order_item ).

Si se define mappedBy , se utilizará OrderItem.order para proporcionar el valor de la relación. De lo contrario, se Order.orderItems .

Para el caso de carga, te ayudará a configurarlo automáticamente.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!