设置 git 提交信息
git 设置用户名邮箱:
对当前项目生效:
git config user.name 'your username'
git config user.email 'your email'
对全局生效,加上 --global:
git config --global user.name 'your username'
git config --global user.email 'your email'
对当前项目生效:
git config user.name 'your username'
git config user.email 'your email'
对全局生效,加上 --global:
git config --global user.name 'your username'
git config --global user.email 'your email'
As an answer to okutane, please see snippet:
@JoinColumn(name = "car_id", insertable = false, updatable = false)
@ManyToOne(targetEntity = Car.class, fetch = FetchType.EAGER)
private Car car;
@Column(name = "car_id")
private Long carId;
So what happens here is that when you want to do an insert/update, you only populate the carId field and perform the insert/update. Since the car field is non-insertable and non-updatable Hibernate will not complain about this and since in your database model you would only populate your car_id as a foreign key anyway this is enough at this point (and your foreign key relationship on the database will ensure your data integrity). Now when you fetch your entity the car field will be populated by Hibernate giving you the flexibility where only your parent gets fetched when it needs to.
answered by 'Jonck van der Kogel'
JPA many-to-one relation - need to save only Id
Java Type | Java DB, Derby, CloudScape | Oracle | DB2 | Sybase | MS-SQL Server | MySQL Server |
---|---|---|---|---|---|---|
boolean, java.lang.Boolean | SMALLINT | NUMBER(1) | SMALLINT | BIT | BIT | TINYINT(1) |
int, java.lang.Integer | INTEGER | NUMBER(10) | INTEGER | INTEGER | INTEGER | INTEGER |
long, java.lang.Long | BIGINT | NUMBER(19) | INTEGER | NUMERIC(19) | NUMERIC(19) | BIGINT |
float, java.lang.Float | FLOAT | NUMBER(19,4) | FLOAT | FLOAT(16) | FLOAT(16) | FLOAT |
double, java.lang.Double | FLOAT | NUMBER(19,4) | FLOAT | FLOAT(32) | FLOAT(32) | DOUBLE |
short, java.lang.Short | SMALLINT | NUMBER(5) | SMALLINT | SMALLINT | SMALLINT | SMALLINT |
byte, java.lang.Byte | SMALLINT | NUMBER(3) | SMALLINT | SMALLINT | SMALLINT | SMALLINT |
java.lang.Number | DECIMAL | NUMBER(38) | DECIMAL(15) | NUMERIC(38) | NUMERIC(28) | DECIMAL(38) |
java.math.BigInteger | BIGINT | NUMBER(38) | BIGINT | NUMERIC(38) | NUMERIC(28) | BIGINT |
java.math.BigDecimal | DECIMAL | NUMBER(38) | DECIMAL(15) | NUMERIC(38) | NUMERIC(28) | DECIMAL(38) |
java.lang.String | VARCHAR(255) | VARCHAR(255) | VARCHAR(255) | VARCHAR(255) | VARCHAR(255) | VARCHAR(255) |
char, java.lang.Character | CHAR(1) | CHAR(1) | CHAR(1) | CHAR(1) | CHAR(1) | CHAR(1) |
byte[], java.lang.Byte[], java.sql.Blob | BLOB(64000) | LONG RAW | BLOB(64000) | IMAGE | IMAGE | BLOB(64000) |
char[], java.lang.Character[], java.sql.Clob | CLOB(64000) | LONG | CLOB(64000) | TEXT | TEXT | TEXT(64000) |
java.sql.Date | DATE | DATE | DATE | DATETIME | DATETIME | DATE |
java.sql.Time | TIME | DATE | TIME | DATETIME | DATETIME | TIME |
java.sql.Timestamp | TIMESTAMP | DATE | TIMESTAMP | DATETIME | DATETIME | DATETIME |
Supported Data Types (Sun Java System Application Server Platform Edition 9 Developer's Guide)
I made an embed page with Spring-boot. The one to show from other sites with iframe. At this time, Spring Security was introduced and the HTTP header "X-Frame-Options" was set to DENY by default, and the embedded page was not displayed.
Since this X-Frame-Options itself should be DENY in order to suppress clickjacking on ordinary pages, I decided that it is better to set not to send this header only on the embedding page. However, "setting X-Frame-Options only for a specific URL" was a little complicated, so I summarized it.
I think that other HTTP Headers can be set for each URL if necessary (unverified).
You should use DecimalFormat("0.#")
For 4.3000
Double price = 4.3000;
DecimalFormat format = new DecimalFormat("0.#");
System.out.println(format.format(price));
output is:
4.3
In case of 5.000 we have
Double price = 5.000;
DecimalFormat format = new DecimalFormat("0.#");
System.out.println(format.format(price));
And the output is:
5
JAVA How to remove trailing zeros from a double