I tried creating an Entity with a nullable @ManyToOne relationship using a @JoinTable. While JPA supports this just fine, I ran into problems when trying to Implement a EclipseLink's HistoryPolicy using an EntityCustomizer.
I wanted to do this:
ManyToOneMapping mapping = (ManyToOneMapping)descriptor.getMappingForAttributeName(FIELD_NAME);
mapping.setHistoryPolicy(...);
Alas, ManyToOneMapping has no setHistoryPolicy() method....it just isn't an implemented feature.
I searched the Web and found little help. Documentation for HistoryPolicy is very light. I did find some suggestions that HistoryPolicy only supports some mappings but not others.
Conclusion: ManyToOne relationships with a JoinTable are not compatible with HistoryPolicy. My workaround is to use a nullable JoinColumn for this relationship.
Wednesday, February 27, 2013
Vaadin JPAContainer JPAContainerItem.setWriteThrough(false) OptimisticLockException
I was getting an OptimisticLockException (OPE) while using Vaadin JPAContainer setWriteThrough(false)
item.setWriteThrough(false);
item.getItemProperty(...).setValue(...);
item.getItemProperty(...).setValue(...);
item.getItemProperty(...).setValue(...);
item.setWriteThrough(true);
But I did not get this error if I setwriteThrough true.
Turns out that the first case calls MutableLocalEntityProvider.updateEntity() while the second case called MutableLocalEntityProvider.updateEntityProperty().
JpaContainerItem holds a reference to an entity that is usually (but not always) detached.
updateEntity() simply merges this entity to the Persistence Context and commits. If the version doesn't match the database, the OPE is thrown.
updateEntityProperty fetches a fresh entity with em.find(), refreshes it, sets the new value, commits and detaches the entity. Only a concurrent write to the database would cause a OPE.
Under both scenarios, setValue() does not cause the Item's referred entity to be refreshed: the version number does not change. Basically, OPE is thrown when updateEntity() called after any changes have been committed.
item.setWriteThrough(false);
item.getItemProperty(...).setValue(...);
item.getItemProperty(...).setValue(...);
item.getItemProperty(...).setValue(...);
item.setWriteThrough(true);
But I did not get this error if I setwriteThrough true.
Turns out that the first case calls MutableLocalEntityProvider.updateEntity() while the second case called MutableLocalEntityProvider.updateEntityProperty().
JpaContainerItem holds a reference to an entity that is usually (but not always) detached.
updateEntity() simply merges this entity to the Persistence Context and commits. If the version doesn't match the database, the OPE is thrown.
updateEntityProperty fetches a fresh entity with em.find(), refreshes it, sets the new value, commits and detaches the entity. Only a concurrent write to the database would cause a OPE.
Under both scenarios, setValue() does not cause the Item's referred entity to be refreshed: the version number does not change. Basically, OPE is thrown when updateEntity() called after any changes have been committed.
Friday, February 22, 2013
Transfer Windows XP Installation CD to USB
I needed to re-install Windows XP on a Netbook before selling it. I transferred the Windows Installation CD to a USB stick using WinToFlash. Worked fine. A little worried about spyware though. The installer tried to install a Firefox plug-in.
http://wintoflash.com/home/en/
-M
http://wintoflash.com/home/en/
-M
Thursday, February 21, 2013
Wiping Hard Drives
I wanted to wipe a hard drive on my old netbook before selling it. I had success by creating a bootable USB stick with DBAN - Darik's Boot and Nuke.
Pen Drive Linux : Installs a OS image (iso) to a USB stick and makes it bootable
http://www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/
DBAN : a small Linux Distro for Nuking Hard disks.
http://sourceforge.net/projects/dban/
DBAN 'autonuke' wipes all drives on the system, including the DBAN USB stick, would be nice to know how to only wipe specified drives....maybe next time.
This looks like a useful tool to have in the box:
http://www.ultimatebootcd.com/
Pen Drive Linux : Installs a OS image (iso) to a USB stick and makes it bootable
http://www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/
DBAN : a small Linux Distro for Nuking Hard disks.
http://sourceforge.net/projects/dban/
DBAN 'autonuke' wipes all drives on the system, including the DBAN USB stick, would be nice to know how to only wipe specified drives....maybe next time.
This looks like a useful tool to have in the box:
http://www.ultimatebootcd.com/
Thursday, January 10, 2013
Itunes Sync: X items could not be synced. See itunes.....
Try Making more space on the device, even if the usage bar in itunes may not be accurate.
Try deleting ipod photo cache.
Try deleting ipod photo cache.
Tuesday, May 22, 2012
StaticWeaveAntTask No source was specified for weaving
Getting the error below when running in Eclipse?
Exception Description: An exception was thrown while weaving: XXXXX
Internal Exception: Exception [EclipseLink-40002] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.StaticWeaveException
Exception Description: No source was specified for weaving
Try running in a separate JRE:
Ant View, Right Click entry, Run As >> External tools configuration
Select this build.xml, JRE, Separate JRE
Exception Description: An exception was thrown while weaving: XXXXX
Internal Exception: Exception [EclipseLink-40002] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.StaticWeaveException
Exception Description: No source was specified for weaving
Try running in a separate JRE:
Ant View, Right Click entry, Run As >> External tools configuration
Select this build.xml, JRE, Separate JRE
Wednesday, May 2, 2012
Postgres puttycyg no password prompt
I couldn't figure out why I would never get a password prompt when
issuing postgres commands in puttycyg/cygwin terminal. Sounds alot like
this issue from 7 years ago.
http://archives.postgresql.org/pgsql-general/2005-11/msg00295.php
Solutions:
Put passwords in here:/AppData/Roaming/postgresql/pgpass.conf
or use the Windows CMD shell.
http://archives.postgresql.org/pgsql-general/2005-11/msg00295.php
Solutions:
Put passwords in here:
or use the Windows CMD shell.
Subscribe to:
Posts (Atom)