我谷歌,但所有示例只在一个对象中显示一个Component
,例如:
我希望在一个对象中有两个Component
,例如:
public class PhoneNumber {
// Phone details
private int areaCode = 0;
private int phoneNumber = 0;
private String name = null;
}
public class Person {
private String firstName = null;
private String nickName = null;
private String lastName = null;
// Multiple phone details
private PhoneNumber homePhone = null;
private PhoneNumber mobilePhone = null;
}
Hibernate映射:
<class name="Person" table="PERSON">
<id name="id" column="PERSON_ID">
<generator class="native"/>
</id>
<property name="firstName" column="FIRST_NAME" />
...
<component name="homePhone" class="PhoneNumber">
<property name="areaCode" column="HOME_AREA_CODE"/>
<property name="phoneNumber" column="HOME_PHONE_NUMBER"/>
<property name="name" column="HOME_NAME"/>
</component>
<component name="mobilePhone" class="PhoneNumber">
<property name="areaCode" column="MOBILE_AREA_CODE"/>
<property name="phoneNumber" column="MOBILE_PHONE_NUMBER"/>
<property name="name" column="MOBILE_NAME"/>
</component>
</class>
我上面有两个Component
,homePhone
和mobilePhone
。如何将Hibernate
以上的映射转换为Java
注释?
答案 0 :(得分:2)
include('databaseconfig.php');
session_start();
$user_check = $_SESSION['login_user'];
$ses_sql = mysqli_query($db,"SELECT nombre FROM pacientes WHERE nombre = '$user_check' ");
$row = mysqli_fetch_array($ses_sql,MYSQLI_ASSOC);
$login_session = $row['nombre'];
if(!isset($_SESSION['login_user'])){
header('location: www.google.co.uk');
}
使用@Embeddable
注释您的电话课程对于每个电话组件,列名称不同。使用@AttributeOverrride并在您实体中指定适当的列名。这会将组件类映射到不同的列。