Page 1 of 1

About Question enthuware.oce-jpad.v6.2.564 :

Posted: Mon Mar 12, 2012 2:21 am
by ETS User
Hi,

I think the last choice is also correct, can anyone explain why it is wrong?

private Integer acctid;
private Double balance;

public Integer getAcctid() { return this.acctid; }
public void setAcctid(Integer acctid) { this.acctid = acctid; }

public Double getBalance() { return this.balance; }
public void setBalance(Double balance) { this.balance = balance; }

Re: About Question enthuware.oce-jpad.v6.2.564 :

Posted: Mon Mar 12, 2012 3:46 pm
by M_Z
Because there are 2 mandatory annotations for ANY entity:

1) @Entity annotation on class (it's assumed in question, just does not shown)
2) Primary key annotation - most often @Id is used, however any of these are possible: @Id, @IdClass, @EmbeddedId

Since the mentioned option does not have PK annotation, it's invalid -- JPA provider does not know how to handle the entity.

Re: About Question enthuware.oce-jpad.v6.2.564 :

Posted: Mon Mar 12, 2012 3:47 pm
by M_Z
One more clarification: @IdClass used only in combination with @Id

Re: About Question enthuware.oce-jpad.v6.2.564 :

Posted: Fri Mar 16, 2012 12:52 am
by peter
It's clear

Re: About Question enthuware.oce-jpad.v6.2.564 :

Posted: Sun Mar 18, 2012 4:15 am
by M_Z
After a second thought, I think you're right - option D also can be selected as correct.

We can define Promary Key information in deployment descriptor (like orm.xml)

Persistence provider uses combination (union) of annotations and XML mappings for it's work (XML has precedence).

So, I think it's a valid situation (although I would say crazy) when developer defines @Entity via annotation, and ID defined like this in orm.xml:

Code: Select all

<entity class="Account">
	<attributes>
		<id name="acctid" />
	</attributes>
</entity>
The question must be more specific if no mapping information is provided in XML.

Re: About Question enthuware.oce-jpad.v6.2.564 :

Posted: Mon Mar 19, 2012 7:01 am
by admin
The question has been updated to make it clear that no mapping information is provided in XML.

thank you for your feedback!

Re: About Question enthuware.oce-jpad.v6.2.564 :

Posted: Sat Mar 31, 2012 3:41 am
by Peter
OK, thanks!

PS I have passed the exam with score 96%

Re: About Question enthuware.oce-jpad.v6.2.564 :

Posted: Sun Apr 01, 2012 7:54 am
by M_Z
Wow ! Congratulations !!! ;)

Your score even better than mine (I got 91%)