//1.Key是基本類型的 @ElementCollection @MapKeyColumn(name="standard") //關聯表中,Map的Key的字段名 @Column(name="price")//關聯表中,Map的Value的字段名 @CollectionTable( name="t_shopping_mall_product_price",//關聯表的名字 joinColumns = { @JoinColumn(name = "product_id")//關聯表的約束於此類的外鍵的名字 } ) public Map<String, Double> getStandardPrice() { return standardPrice; } //2.Key是實體類型的 @ElementCollection(fetch = FetchType.EAGER) @MapKeyColumn(name = "driver_id",length = 32) @Column(name = "goods_number",length = 150) @CollectionTable( name = "t_package_order", joinColumns = { @JoinColumn(name = "order_id") } ) public Map<Driver, String> getDriverGoodsMap() { return driverGoodsMap; } //Value是基本數據類型和實體數據類型的寫法與Key的類似