many-to-one

Spring Boot @ManyToOne only Id @JsonProperty

徘徊边缘 提交于 2021-01-29 09:00:21
问题 help me find JSON property annotation who give me choose an entity property to JSON serialization. I need only one. I code like that: @Entity @Table(name = "pages") public class Page { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") private Long id; @Column(name = "name") private String name; @JsonIgnoreProperties(value = {"name", "description", "pages"}) // it's working, but I want to simplify, I need only project id property to JSON @ManyToOne(fetch = FetchType

How to save parent and child in one shot (JPA & Hibernate)

本小妞迷上赌 提交于 2020-12-29 11:57:45
问题 I start showing you my scenario. This is my parent object: @Entity @Table(name="cart") public class Cart implements Serializable{ @GeneratedValue(strategy=GenerationType.IDENTITY) @Id @Column(name="id") private Integer id; @OneToMany(mappedBy="cart", fetch = FetchType.EAGER, cascade = CascadeType.ALL) private List<CartItem> cartItems; ... } This is my child object: @Entity @Table(name="cart_item") public class CartItem implements Serializable{ @GeneratedValue(strategy=GenerationType.IDENTITY)

FetchType.LAZY not working for @ManyToOne mapping in hibernate

ⅰ亾dé卋堺 提交于 2020-01-25 09:27:06
问题 Simply put I have a many to one relation on the Child class with the Parent class. I want to load all the children without having to load their parent details. My child class is @Entity public class Child implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String name; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "parentId", referencedColumnName = "id") private Parent parent; public Child() { } // Getters and setters here } My

NHibernate always hydrates many-to-one

巧了我就是萌 提交于 2020-01-15 12:35:07
问题 I am experiencing something weird when using NHibernate. I have opened up a codebase that I didn't write, and the one who did isn't here anymore. So I guess what I am looking for is more tips on debugging than anything else. I am using NHIbernate 3.4 Linq provider, to query an entity, that has a many-to-one relationship to another entity. What I see is the even though I never access the property that represents the many-to-one relation it is always hydrated. From looking at the queries

Hibernate ManyToOne with FetchType.LAZY not fetching lazy

雨燕双飞 提交于 2020-01-11 00:09:16
问题 I am using Hibernate with spring. I have a model-class like this. @Entity @Table(name = "forumtopic") public final class Forumtopic extends AbstractUserTracking implements java.io.Serializable { /**SNIP **/ private Forumcategory forumcategory; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "FkForumcategoryId", nullable = false) public Forumcategory getForumcategory() { return this.forumcategory; } public void setForumcategory(final Forumcategory forumcategory) { this.forumcategory =

Many-to-one relationship in SQLAlchemy

二次信任 提交于 2020-01-05 07:16:53
问题 This is a beginner-level question. I have a catalog of mtypes: mtype_id name 1 'mtype1' 2 'mtype2' [etc] and a catalog of Objects, which must have an associated mtype: obj_id mtype_id name 1 1 'obj1' 2 1 'obj2' 3 2 'obj3' [etc] I am trying to do this in SQLAlchemy by creating the following schemas: mtypes_table = Table('mtypes', metadata, Column('mtype_id', Integer, primary_key=True), Column('name', String(50), nullable=False, unique=True), ) objs_table = Table('objects', metadata, Column(

Properly modify object with @ManyToOne relationship in Spring MVC + Hibernate app

核能气质少年 提交于 2020-01-03 02:51:57
问题 After days of torture to resolve this issue and reading everything I could find on SO I decided to ask. I'm having trouble understanding what I read here on Hibernate site, so I'll explain my situation. I have object student that contains object program : @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch=FetchType.EAGER) @JoinColumn(name = "PROGRAM_FK", nullable = false) private Program program; In my service method I want o change/update only program for a student: public