Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

svn commit: r425175 - in /shale/sandbox/mailreader-jpa/src/main: java/org/a: msg#00047

apache.shale.scm

Subject: svn commit: r425175 - in /shale/sandbox/mailreader-jpa/src/main: java/org/apache/mailreaderjpa/Protocol.java java/org/apache/mailreaderjpa/Subscription.java java/org/apache/mailreaderjpa/User.java resources/META-INF/persistence.xml

Author: craigmcc
Date: Mon Jul 24 13:16:09 2006
New Revision: 425175

URL: http://svn.apache.org/viewvc?rev=425175&view=rev
Log:
[SHALE-225] Further improvements to JPA entity classes

* Use a non-JTA transaction type, so that application logic
can consistently use EntityTransaction in both standalone
and web applications.

* Correct equals() implementation to not throw NPE when
the "id" property has not yet been set (for example,
when a new instance is being compared to an old one).

* Tweak User.removeSubscription() to not attempt to set
the "user" property of the subscription to null. This
was causing an update to the underlying database to set
the USER_ID column to null, which would fail due to a
NOT NULL integrity constraint.


Modified:

shale/sandbox/mailreader-jpa/src/main/java/org/apache/mailreaderjpa/Protocol.java

shale/sandbox/mailreader-jpa/src/main/java/org/apache/mailreaderjpa/Subscription.java

shale/sandbox/mailreader-jpa/src/main/java/org/apache/mailreaderjpa/User.java
shale/sandbox/mailreader-jpa/src/main/resources/META-INF/persistence.xml

Modified:
shale/sandbox/mailreader-jpa/src/main/java/org/apache/mailreaderjpa/Protocol.java
URL:
http://svn.apache.org/viewvc/shale/sandbox/mailreader-jpa/src/main/java/org/apache/mailreaderjpa/Protocol.java?rev=425175&r1=425174&r2=425175&view=diff
==============================================================================
---
shale/sandbox/mailreader-jpa/src/main/java/org/apache/mailreaderjpa/Protocol.java
(original)
+++
shale/sandbox/mailreader-jpa/src/main/java/org/apache/mailreaderjpa/Protocol.java
Mon Jul 24 13:16:09 2006
@@ -61,7 +61,8 @@
}

public boolean equals(Object obj) {
- if (obj instanceof Protocol) {
+ if ((obj instanceof Protocol)
+ && (getId() != null)) {
return getId().equals(((Protocol) obj).getId());
} else {
return false;

Modified:
shale/sandbox/mailreader-jpa/src/main/java/org/apache/mailreaderjpa/Subscription.java
URL:
http://svn.apache.org/viewvc/shale/sandbox/mailreader-jpa/src/main/java/org/apache/mailreaderjpa/Subscription.java?rev=425175&r1=425174&r2=425175&view=diff
==============================================================================
---
shale/sandbox/mailreader-jpa/src/main/java/org/apache/mailreaderjpa/Subscription.java
(original)
+++
shale/sandbox/mailreader-jpa/src/main/java/org/apache/mailreaderjpa/Subscription.java
Mon Jul 24 13:16:09 2006
@@ -69,7 +69,8 @@
}

public boolean equals(Object obj) {
- if (obj instanceof Subscription) {
+ if ((obj instanceof Subscription)
+ && (getId() != null)) {
return getId().equals(((Subscription) obj).getId());
} else {
return false;

Modified:
shale/sandbox/mailreader-jpa/src/main/java/org/apache/mailreaderjpa/User.java
URL:
http://svn.apache.org/viewvc/shale/sandbox/mailreader-jpa/src/main/java/org/apache/mailreaderjpa/User.java?rev=425175&r1=425174&r2=425175&view=diff
==============================================================================
---
shale/sandbox/mailreader-jpa/src/main/java/org/apache/mailreaderjpa/User.java
(original)
+++
shale/sandbox/mailreader-jpa/src/main/java/org/apache/mailreaderjpa/User.java
Mon Jul 24 13:16:09 2006
@@ -76,7 +76,8 @@
}

public boolean equals(Object obj) {
- if (obj instanceof User) {
+ if ((obj instanceof User)
+ && (getId() != null)) {
return getId().equals(((User) obj).getId());
} else {
return false;
@@ -167,7 +168,10 @@
List<Subscription> subscriptions = getSubscriptions();
if (subscriptions.contains(subscription)) {
subscriptions.remove(subscription);
- subscription.setUser(null);
+ // Commment out following line because it seems to cause
+ // an update of the USER_ID column setting it to null, which
+ // would violate the database integrity constraints
+// subscription.setUser(null);
}
}


Modified:
shale/sandbox/mailreader-jpa/src/main/resources/META-INF/persistence.xml
URL:
http://svn.apache.org/viewvc/shale/sandbox/mailreader-jpa/src/main/resources/META-INF/persistence.xml?rev=425175&r1=425174&r2=425175&view=diff
==============================================================================
--- shale/sandbox/mailreader-jpa/src/main/resources/META-INF/persistence.xml
(original)
+++ shale/sandbox/mailreader-jpa/src/main/resources/META-INF/persistence.xml
Mon Jul 24 13:16:09 2006
@@ -20,7 +20,20 @@
*/
-->

-<!-- Persistence unit for a predeployed data source on a Java EE 5 server -->
+<!-- Persistence unit for a predeployed data source on a Java EE 5 server
+ using RESOURCE_LOCAL transactions -->
+<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence";>
+ <persistence-unit name="MailReaderJpa" transaction-type="RESOURCE_LOCAL">
+
<provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
+ <non-jta-data-source>jdbc/mailreader</non-jta-data-source>
+ <properties>
+ <property name="toplink.ddl-generation" value="create-tables"/>
+ </properties>
+ </persistence-unit>
+</persistence>
+
+<!-- Persistence unit for a predeployed data source on a Java EE 5 server
+ using JTA transactions
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence";>
<persistence-unit name="MailReaderJpa" transaction-type="JTA">

<provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
@@ -30,6 +43,7 @@
</properties>
</persistence-unit>
</persistence>
+-->

<!-- Persistence unit for standalone JPA implementation
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence";>





<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
video.h264.deve...    technology.erps...    drivers.hostap/...    user-groups.lin...    games.railroad-...    handhelds.linux...    lang.harbour.de...    recreation.radi...    culture.publica...    xfree86.devel/2...    music.john-cage...    otrs.cvs/2003-0...    network.e-smith...    asplinux.suppor...    qnx.openqnx.dev...    ietf.nfsv4/2005...    editors.vim/200...    kde.devel.kopet...    web.zope.zwiki....    freebsd.devel.m...    java.xdoclet.de...    php.simpletest....    bacula.user/200...    security.virus....   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation