aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate persistence not throwing EntityExistsException on persist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate persistence not throwing EntityExistsException on persist" Watch "Hibernate persistence not throwing EntityExistsException on persist" New topic
Author

Hibernate persistence not throwing EntityExistsException on persist

Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

Hi all,

I have the following code which,if you have a look at it,should throw java.lang.EntityExistsException BUT.....
it doesn't..am I missing something here ?



===>SCJP 1.5(72%)<===
==>SCWCD1.5(76%)<===
Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

Anybody?
See Furst
Greenhorn

Joined: Aug 04, 2010
Posts: 29
That's a subclass of java.lang.Exception? or Throwable?

javadocs doesn't list it?

AclNotFoundException, ActivationException, AlreadyBoundException, ApplicationException, AWTException, BackingStoreException, BadAttributeValueExpException, BadBinaryOpValueExpException, BadLocationException, BadStringOperationException, BrokenBarrierException, CertificateException, ClassNotFoundException, CloneNotSupportedException, DataFormatException, DatatypeConfigurationException, DestroyFailedException, ExecutionException, ExpandVetoException, FontFormatException, GeneralSecurityException, GSSException, IllegalAccessException, IllegalClassFormatException, InstantiationException, InterruptedException, IntrospectionException, InvalidApplicationException, InvalidMidiDataException, InvalidPreferencesFormatException, InvalidTargetObjectTypeException, InvocationTargetException, IOException, JAXBException, JMException, KeySelectorException, LastOwnerException, LineUnavailableException, MarshalException, MidiUnavailableException, MimeTypeParseException, MimeTypeParseException, NamingException, NoninvertibleTransformException, NoSuchFieldException, NoSuchMethodException, NotBoundException, NotOwnerException, ParseException, ParserConfigurationException, PrinterException, PrintException, PrivilegedActionException, PropertyVetoException, RefreshFailedException, RemarshalException, RuntimeException, SAXException, ScriptException, ServerNotActiveException, SOAPException, SQLException, TimeoutException, TooManyListenersException, TransformerException, TransformException, UnmodifiableClassException, UnsupportedAudioFileException, UnsupportedCallbackException, UnsupportedFlavorException, UnsupportedLookAndFeelException, URIReferenceException, URISyntaxException, UserException, XAException, XMLParseException, XMLSignatureException, XMLStreamException, XPathException

those are the known ones anyway.. perhaps this exception is Hibernate specific?

That exception isn't even listed as an irregular exception:

ExceptionInInitializerError, ClassNotFoundException, UndeclaredThrowableException, InvocationTargetException, WriteAbortedException, PrivilegedActionException, PrinterIOException, RemoteException and NamingException

These are Throwable(s) not Exception(s)... so I'm not sure if your exception exists.. At least not in java.lang.


Doin' Java to be one of the cool kids.
I usually use Perl;
Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

Sorry I meant javax.persistence.EntityExistsException..I'm not using Hibernate...just using it as the persistence provider
Megan Troy
Greenhorn

Joined: Jul 27, 2005
Posts: 10
As per the specs:
If X is a preexisting managed entity, it is ignored by the persist operation.

So, the code is behaving as expected.
Megan Troy
Greenhorn

Joined: Jul 27, 2005
Posts: 10
As per the specs:
If X is a preexisting managed entity, it is ignored by the persist operation.

So, the code is behaving as expected.
Megan Troy
Greenhorn

Joined: Jul 27, 2005
Posts: 10
As per the specs:
If X is a preexisting managed entity, it is ignored by the persist operation.

So, I guess the code is working as expected as you have an application-managed entity manager
Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

Ah thanks so much...I hadn't considered that it would only be thrown if the entity was unmanaged
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate persistence not throwing EntityExistsException on persist
 
Similar Threads
EntityExistsException
JPA-Hibernate - EntityExistsException Question
EntityExistsException how to know which key i duplicate?
Hibernate JPA persist() not throwing EntityExistsException
EntityExistsException