Hibernate 映射檔或註解中,表名若寫成 t-user (含連字號) 會報 MappingException: Table not found,因資料庫識別符通常不允許連字號,或 Hibernate 解析時將其視為減法運算。
<!-- 錯誤 -->
<class name="User" table="t-user"> ... </class>
<!-- 正確 -->
<class name="User" table="t_user"> ... </class>
或註解式:
@Entity
@Table(name = "t_user") // 底線而非連字號
public class User { ... }
t_user, create_time。hibernate.cfg.xml 可設定 hibernate.implicit_naming_strategy 自動駝峰轉底線。table="`t-user`" (MySQL) 或 table="\"t-user\"" (PostgreSQL),但強烈建議重命名表。