Tamas Polgar

Greenhorn
+ Follow
since Apr 27, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
2
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tamas Polgar

Hi,

I would say about 15%.
However the questions are very long, to read them takes about 5min, very similar options. Save time for them.

good luck
Hibernate is quite far from the spec, if you want to play with nested embeddables, and element collections, you could have problems with hibernate.
eclipselink's behaviour is ok by the spec.

but hibernate builds much better queries than openjpa/eclipselink.

we can choose from different implementations fortunately
hi,
I've just passed the test today, it was quite tough, but ok.
The time was just enough, I didn't have to hurry.
Questions with lot of text, and code waste a lot of time, especially criteria query questions.

I used http://www.epractizelabs.com/certification/sun/oce-jpa-exam-6.html. It was only 26 GBP, so it was an ok deal.
It contains few questions which are similar to the real exams' questions, so for the questions it's worth.
But the program is absolutely useless, it has lot of bad answers, but currently the only mock exam in the market

I used the Pro JPA2 book, and the specification.

Regards,
hi,

its a good question, as you wrote:
"If X is a removed entity instance, an IllegalArgumentException will be thrown by the merge operation (or the transaction commit will fail)."

if it doesnt throw an IllegalArgumentException your transaction wont fail.
It's not strictly described by the specification.
the main goal is to prevent the database from illegal updates/inserts.
and in your case you dont have illegal updates/insterts

however it's strange..
eclipselink/toplink doesnt throw IllegalArgumentException, but hibernate does.
ok, I get it.

No, you can not queue it. It immediatelly starts to synchronize the pc with the db. And for this you need a transaction.

But why would you like to queue the flush operation?
Sorry

you need a transaction to flush your changes you made during the transaction


is not properly right. It syncronizes the persistence context with the db.

so if you queue your modifications by using business methods without transaction, you can explicitly flush at the remove method (with transaction)
(but flush can happen anytime!)

check this out:
http://thatjavathing.blogspot.com/2009/04/extended-persistence-context.html
Hi,
you need a transaction to flush your changes you made during the transaction
so throwing a TransactionRequiredException makes a lot of sense.

if you use extended persistence context (with container managed transaction), it commits (flushes) after all business method (which uses transaction) invocation.
but it doesnt close (clear) the persistence context after the transaction. so you can use managed entities during the lifetime of the stateful session bean.

did I answer you question? or could you be more specific?
Hi,
This topic is not exactly clear for me

I have few examples

I have a stateless bean:


(1,3,5)
NonUniqueResultException should NOT mark the transaction rollback. But the call throws an Exception.
Should the new user be saved?

(2,4)
EntityNotFoundException should mark the transaction rollback. But I catch the exception.
Should the new user be saved?

I tried them with jboss,
1: rolled back
2: didnt roll back
3: rolled back
4: rolled back
5: rolled back

But I think the output should be different

?

Thank you
Hi All,

I'm preparing for the oracle jpa certification (cx-310-094 / iz0-898), but I cannot find any useful information
Could anybody who passed this exam share the experiences with us?
Does anybody know a mock exam for it?

Thank You
There are no sequences in mysql,
you can use id generation (when you insert the record, it generates an id, dont use it for complex relationships), or table generator which is quite cool (details).

so I created a simple version of your stuff
Answer:

xml for it:

Question

xml:

sql script:

It works for me, with hibernate as well.
Note:
many-to-one and one-to-many are the last elements of the mappings. with hibernate it seems to be required..
You dont need to use basic if you use default values (other attribute = other column). Try to use default values, it can reduce the code, and improves the readability.

you can use annotation or xml, or both. you can specify the same mapping with xml and annotations (in theory ).
however annotations could be easier to understand how jpa works.
Hi,
using hibernate as jpa2 provider could produce wierd situations

For your first problem:
If you change the order of your attribute mappings in Answer, and put <many-to-one name="question"/> to the last statement, it should pass the XMLSchemaValidation. It shouldnt be a problem with a jpa2 provider, but with hibernate, it is.
You use <one-to-many name="answers" mapped-by="answerId"> in your Question, this should be mapped by an attribute with Question type, with many-to-one relation type.

For your second problem
and

are not good, you cannot use one-to-many or many-to-one in the id tag.
Try to put them outside the id, and sculp it a bit

How does the datamodel look like?
Hi there,

From JPA spec (http://download.oracle.com/javaee/6/api/javax/persistence/Embedded.html)
"Specifies a persistent field or property of an entity whose value is an instance of an embeddable class. The embeddable class must be annotated as Embeddable. "

For me it means you should use it for single attributes, not collections. Howewer, the annotation api doesnt deny it, and with eclipselink, and hibernate it works for me.
but in the xml api, which is better-defined, its not allowed.

So I think you should not use it,
the generic type, or the targetClass attribute of @ElementCollection is enough.