I am a beginner with less than a month of java history. I will leave it as a memorandum for myself.
To the model class found from table I wanted to have a parameter with a field name that doesn't exist in the column. In php (I can't recommend it very much), if you declare the variable as it is, you can use it normally. I thought I could do it with java.
There is no name column in the Hoge table When you want to get it from the outside or dynamically process it with hoge
@Entity
public class hoge {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String name;
If this happens
Caused by: java.sql.SQLException: Column 'name' not found.
I got scolded. Like PHP, it doesn't come in as null It seems to be useless because there is no data to see
Use the @Transient
annotation to exclude it from mapping.
Originally it seems to be an annotation to exclude it from persistence
It seems that it will be excluded from mapping due to that effect (I'm sorry if it is different)
@Entity
public class hoge {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Transient
private String name;
I'm no longer angry
When studying java You can see how well I was coding in PHP.
Recommended Posts