<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/schedule?useSSL=false&autoReconnect=true </property>
<property name="connection.username">root</property>
<property name="connection.password">1234</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect"
>org.hibernate.dialect.MySQLDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class"
>thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class"
>org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql"
>true</property>
<property name="format_sql">true</property>
<property name="hibernate.c3p0.acquire_increment">1</property>
<property …Run Code Online (Sandbox Code Playgroud) class Overflowtest {
public static void main(String[] args) {
byte maxValue= Byte.MAX_VALUE;
System.out.println("maxValue of byte is "+maxValue);
System.out.println("add 1 to maxValue of byte is "+maxValue+(byte)2);
}
}
Run Code Online (Sandbox Code Playgroud)
为什么我尝试时没有发生溢出maxValue+(byte)2?但如果我这样做(byte)(maxValue+2),溢出就发生了.