Oracle 1z0-898 Exam Practice Questions (P. 5)
- Full Access (63 questions)
- Six months of Premium Access
- Access to one million comments
- Seamless ChatGPT Integration
- Ability to download PDF files
- Anki Flashcard files for revision
- No Captcha & No AdSense
- Advanced Exam Configuration
Question #21
The developer wants to define a unidirectional relationship from the customer entity to the order entity and map this relationship using a foreign key mapping strategy.
Which one of the pairs of classes below correctly achieves this task?
Which one of the pairs of classes below correctly achieves this task?
- A@Entity public class Customer { @Id int customerId; @OneToMany @JoinColumn (name = "CUST_ID") Set <Order> orders; . . . } @Entity public class order { @Id int orderId; . . . }
- B@Entity public class Customer { @Id int customerId; @OneToMany Set <Order> orders; . . . } @Entity @JoinColumn (names = "CUST-ID", referencedColumnName = "customerId") public class order { @Id int order Id; . . . }
- C@Entity public class Customer { @Id int customerId; @OneToMany (JoinColumn = @joinColumn (name = "CUST_ID") Set <Order> orders; . . . } @Entity public class order { @Id int orderId; . . . }
- D@ Entity public class Customer { @Id int customerId; @OneToMany (JoinColumn = @JoinColumn (name = "CUST_ID"), table = ""ORDER) Set <Order> orders; . . . } @Entity public class order { @Id int orderId; . . .
Correct Answer:
A
JoinColumn specifies a column for joining an entity association or element collection.
Example: unidirectional one-to-many association using a foreign key mapping
// In Customer class
@OneToMany
@JoinColumn(name="CUST_ID") // join column is in table for Order public Set<Order> getOrders() {return orders;}
Reference: javax.persistence, Annotation Type JoinColumn
A
JoinColumn specifies a column for joining an entity association or element collection.
Example: unidirectional one-to-many association using a foreign key mapping
// In Customer class
@OneToMany
@JoinColumn(name="CUST_ID") // join column is in table for Order public Set<Order> getOrders() {return orders;}
Reference: javax.persistence, Annotation Type JoinColumn
send
light_mode
delete
Question #22
A developer who is designing entity classes to map a legacy database encounters a table called STUDENT_RECORD.
This table has two columns, STUDENT_ID and STUDENT_INFO_ID. The primary key of this table consists of both columns, and there is a unique constraint on each info column.
The STUDENT_ID column is foreign key to the STUDENT table and STUDENT_INFO_ID column is a foreign key to the STUDENT_DAT table.
What entity classes and relationships can the developer use to model these tables and relationship?(Choose two)
This table has two columns, STUDENT_ID and STUDENT_INFO_ID. The primary key of this table consists of both columns, and there is a unique constraint on each info column.
The STUDENT_ID column is foreign key to the STUDENT table and STUDENT_INFO_ID column is a foreign key to the STUDENT_DAT table.
What entity classes and relationships can the developer use to model these tables and relationship?(Choose two)
- AModel the student table as a student entity and STUDENT_DATA table StudentData entity. Model the STUDENT_RECORDS table as bidirectional many-to- many relationship between the student entity on the student data entity.
- BModel the STUDENT table as a Student entity and the STUDENT-DATA table as a StudentData entity. Model the STUDENT_RECORD table as a bidirectional one-to-one relationship between the student entity and the StudentData entity.
- CModel the STUDENT table as a Student entity and the STUDENT-DATA table as a StudentData entity. Model the Student-Records table as a student record entity. Create a many-to-one one relationship from the StudentRecord entity to the student entity and many-to-one relationship from the student entity to the StudentData entity and one-to-many relationship from the StudentData entity to the StudentRecord entity.
- DModel the STUDENT table as a Student entity and the STUDENT-DATA table as a StudentData entity. Model the STUDENT-RECORD table as a StudentRecord entity. Create a bidirectional one-to-one relationship between the StudentRecord entity and bidirectional one-to-one relationship between the
Correct Answer:
AC
There is a many-to-many relationship between the Student table and the Student_table. This can be modeled with one many-to-many relation (A) or two many-to- one relations (C).
Incorrect -
not B, not D: Not a one-one relationship.
AC
There is a many-to-many relationship between the Student table and the Student_table. This can be modeled with one many-to-many relation (A) or two many-to- one relations (C).
Incorrect -
not B, not D: Not a one-one relationship.
send
light_mode
delete
Question #23
The developer is creating a Java Persistence model for a legacy database. The database contains customer and subscriptions.
The subscriptions table has a foreign key to the Customer table, a foreign key to the magazines table, and a column that stores a java.util.Date (the subscription expiration date).
The developer wants to create entities Customer and subscription to model these tables and to represent the relationship between customer and subscription as a java.util.Map.
Which one of the following fields of the Customer entity accomplishes this task?
The subscriptions table has a foreign key to the Customer table, a foreign key to the magazines table, and a column that stores a java.util.Date (the subscription expiration date).
The developer wants to create entities Customer and subscription to model these tables and to represent the relationship between customer and subscription as a java.util.Map.
Which one of the following fields of the Customer entity accomplishes this task?
- A@OneToMany @joinColumn (name = "Customer - FK") Map <Magzine, Data> subscriptions;
- B@ElementCollection Map <Magzine, Data> subscriptions
- C@OneToMany @JoinTable (name = "Subscriptions") Map <Magzine, Data> subscriptions;
- D@ElementCollection @CollectionTable (name = "subscriptions") Map <Magazine, Data> subscriptions
- E@ElementCollection @CollectionTable (Name = "Subscriptions") @Temporal (TemporalType.DATE)
Correct Answer:
E
* The ElementCollection values are always stored in a separate table. The table is defined through the @CollectionTable annotation or the <collection-table> element.
* Annotation Type Temporal
This annotation must be specified for persistent fields or properties of type java.util.Date and java.util.Calendar.
Reference: javax.persistence, Annotation Type Temporal
E
* The ElementCollection values are always stored in a separate table. The table is defined through the @CollectionTable annotation or the <collection-table> element.
* Annotation Type Temporal
This annotation must be specified for persistent fields or properties of type java.util.Date and java.util.Calendar.
Reference: javax.persistence, Annotation Type Temporal
send
light_mode
delete
Question #24
Refer to the Exhibit.

A developer wants to have bookingdata stored in the table BOOKING, flightnumber in table FLIGHTBOOKING, and hotel name in HOTELBOOKING.
Which code, inserted at line 11 of class Booking, is appropriate for his strategy?

A developer wants to have bookingdata stored in the table BOOKING, flightnumber in table FLIGHTBOOKING, and hotel name in HOTELBOOKING.
Which code, inserted at line 11 of class Booking, is appropriate for his strategy?
- A@Joined
- B@SingleTable
- C@TablePerClass
- D@Inheritance (strategy = JOINED)
- E@Inheritance (strategy = SINGLE_TABLE)
- F@Inheritance (strategy = TABLE_PER_CLASS)
Correct Answer:
D
The InheritanceType.SINGLE_TABLE strategy maps all classes in the hierarchy to the base class' table.
Example:

In our model, Subscription is mapped to the CNTRCT.SUB table. LifetimeSubscription, which extends Subscription, adds its field data to this table as well.
@Entity
@Table(name="SUB", schema="CNTRCT")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
public class Subscription {
...
}
@Entity(name="Lifetime")
public class LifetimeSubscription
extends Subscription {
...
}
Reference: Chapter 12. Mapping Metadata, 6. Inheritance
D
The InheritanceType.SINGLE_TABLE strategy maps all classes in the hierarchy to the base class' table.
Example:

In our model, Subscription is mapped to the CNTRCT.SUB table. LifetimeSubscription, which extends Subscription, adds its field data to this table as well.
@Entity
@Table(name="SUB", schema="CNTRCT")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
public class Subscription {
...
}
@Entity(name="Lifetime")
public class LifetimeSubscription
extends Subscription {
...
}
Reference: Chapter 12. Mapping Metadata, 6. Inheritance
send
light_mode
delete
Question #25
Which two of the following statements are true of embeddable classes? (Choose two)
- AAn embeddable class must not be used to represent the state of another embeddable class.
- BNull comparison operations over embeddable classes are not supported in the Java Persistence query language.
- CAn embeddable class must not contain a relationship to an entity.
- DAn embeddable class can be the key of a Map relationship.
Correct Answer:
BD
Not A: Embeddable classes may themselves use other embeddable classes to represent their state. They may also contain collections of basic Java programming language types or other embeddable classes.
Not C: Embeddable classes may also contain relationships to other entities or collections of entities. If the embeddable class has such a relationship, the relationship is from the target entity or collection of entities to the entity that owns the embeddable class.
Note: Embeddable classes are used to represent the state of an entity but dont have a persistent identity of their own, unlike entity classes. Instances of an embeddable class share the identity of the entity that owns it. Embeddable classes exist only as the state of another entity. An entity may have single-valued or collection-valued embeddable class attributes.
Reference: The Java EE 6 Tutorial, Embeddable Classes in Entities
BD
Not A: Embeddable classes may themselves use other embeddable classes to represent their state. They may also contain collections of basic Java programming language types or other embeddable classes.
Not C: Embeddable classes may also contain relationships to other entities or collections of entities. If the embeddable class has such a relationship, the relationship is from the target entity or collection of entities to the entity that owns the embeddable class.
Note: Embeddable classes are used to represent the state of an entity but dont have a persistent identity of their own, unlike entity classes. Instances of an embeddable class share the identity of the entity that owns it. Embeddable classes exist only as the state of another entity. An entity may have single-valued or collection-valued embeddable class attributes.
Reference: The Java EE 6 Tutorial, Embeddable Classes in Entities
send
light_mode
delete
All Pages