Coder Social home page Coder Social logo

appoxy / simplejpa Goto Github PK

View Code? Open in Web Editor NEW
52.0 52.0 35.0 184 KB

SimpleJPA - Java Persistence API (JPA) implementation for Amazon SimpleDB

Home Page: http://www.appoxy.com

License: Apache License 2.0

Shell 0.02% Java 97.41% Groovy 2.52% HTML 0.05%

simplejpa's People

Contributors

aldrinleal avatar andrewkl avatar benjchristensen avatar cast avatar cbolduc avatar grouchal avatar kerrywright avatar lthuangiang avatar treeder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simplejpa's Issues

Cascade support?

Does SimpleJPA support cascade annotations?

I tried @OneToMany(mappedBy = "...", cascade = CascadeType.ALL) with no effect.

Unable to find javax.mail:mail:jar:1.4.5-SNAPSHOT

Which maven repository contains references to the mail.jar SNAPSHOT?

mvn install

[INFO] Scanning for projects...

[INFO] --------------------------------------------------------------------

[INFO] Building SimpleJPA
[INFO] task-segment: [install]

[INFO] --------------------------------------------------------------------

[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resour
ces, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory c:\workspace\work\os\amazon\simp
lejpa\core\src\main\resources

[INFO] --------------------------------------------------------------------

[ERROR] BUILD ERROR

[INFO] --------------------------------------------------------------------

[INFO] Failed to resolve artifact.

Failed to resolve artifact, possibly due to a repository list that is not a
ppropriately equipped for this artifact's metadata.
javax.mail:mail:jar:1.4.5-SNAPSHOT

from the specified remote repositories:
central (http://repo1.maven.org/maven2)

Path to dependency:
1) SimpleJPA:SimpleJPA:jar:1.6-SNAPSHOT
2) com.amazonaws:aws-java-sdk:jar:1.1.8
3) javax.mail:mail:jar:1.4.5-SNAPSHOT

[INFO] --------------------------------------------------------------------

[INFO] For more information, run Maven with the -e switch

[INFO] --------------------------------------------------------------------

[INFO] Total time: 1 second
[INFO] Finished at: Wed Aug 10 14:47:09 IST 2011
[INFO] Final Memory: 8M/20M

[INFO] --------------------------------------------------------------------

replaceClassName behaviour

Hi,

I just tried to do a native 'select * from JPAUserMessage'.
I got an error. It looks like SimpleDBQuery.replaceClassName() isn't doing well.

I mimic line 67 with the above query:
String persistenceUnitName = "PU";
String className = ""; !!
String test = "select count() from PU-JPAUserMessage".replaceFirst(className, ""+persistenceUnitName+"-JPAUserMessage");
this results in "'PU-JPAUserMessage' select count(
) from 'PU-JPAUserMessage'"
so, when the className resolves to "" by matcher.find (which it does for the above query), the select expression isn't correct anymore.

Regards,
Duncan

Not equals query error

Hi there,

I am wondering if anyone experience issue with <> (not equal) query.
I am not sure if there is something wrong with my code, or if this actually a bug on SimpleJPA or SimpleDB

I receive below error when using '<>' operand in my query:

Status Code: 400, AWS Request ID: f1f24508-e5c9-b307-7eed-4737e3fb4c2d, AWS Error Code: InvalidQueryExpression, AWS Error Message: The specified query expression syntax is not valid.
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:500)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:262)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:166)
at com.amazonaws.services.simpledb.AmazonSimpleDBClient.invoke(AmazonSimpleDBClient.java:739)
at com.amazonaws.services.simpledb.AmazonSimpleDBClient.select(AmazonSimpleDBClient.java:197)
at com.spaceprogram.simplejpa.DomainHelper.selectItems(DomainHelper.java:57)

I have also tried to use '!=' but it does not seem to work:

javax.persistence.PersistenceException: No getter for field: status !
at com.spaceprogram.simplejpa.query.QueryImpl.appendCondition(QueryImpl.java:365)
at com.spaceprogram.simplejpa.query.QueryImpl.toAmazonQuery(QueryImpl.java:270)
at com.spaceprogram.simplejpa.query.QueryImpl.createAmazonQuery(QueryImpl.java:173)
at com.spaceprogram.simplejpa.query.QueryImpl.getResultList(QueryImpl.java:104)

at

If I remove the <> operand then the query runs with no problem. Here is my code snippet:

....
em = factory.createEntityManager();
Query query = em.createQuery("select s from Stuff s where owner=:owner AND status <> :status AND created is not null order by created desc");
query.setParameter("owner", owner);
query.setParameter("status", status);
return (List)query.getResultList();

....

Thanks.

@GeneratedValue

Please implements @GeneratedValue annotation for simplejpa.

Using EntityManagerFactoryImpl.newInstanceWithClassNames doesn't work on Mac OS

NB This is Issue 39 at google code: http://code.google.com/p/simplejpa/issues/detail?id=39

What steps will reproduce the problem?
1.Call the method EntityManagerFactoryImpl.newInstanceWithClassNames with a list of class names that are located in a jar file and run on MAC OS X
2.Run a query against the EntityManager referencing one of the classes loaded from the jar file - exception thrown with file not found.

What is the expected output?
Should run without exception
What do you see instead?
A FileNotFoundException

What version of the product are you using? On what operating system?
1.6-SNAPSHOT on OSX 10.6.7

Please provide any additional information below.
The problem is actually caused in the method getLibsToScan

the line :

libs.add(resource.getFile().split("!")[0].substring(6));

is stripping off the leading slash so that

file:/Users/..... becomes Users/.....

this maybe what is required on Windows, but breaks on Mac OS and possibly also on *nix

Changing the line to:

libs.add(resource.getFile().split("!")[0].substring(5));

solves the problem but I would like someone to test on Windows before I commit the change.

Wrong value in numeric fields

EntityManagerSimpleJPA.OFFSET_VALUE applied in public T convert(Collection values, PersistentProperty property, Class retType) method in EntityManagerSimpleJPA causes negative value in entity long fields.

@Enumerated doesn't work on fields

I can't claim to be an expert on the JPA spec, but I've at least seen examples implying that @Enumerated(EnumType.STRING) should work on the field level in addition to the getter. SimpleJPA only works on the getter. Don't get me wrong, I'm glad there's a fix to my pain, but shouldn't this annotation also work at the field level?

Thanks - this is an excellent tool you've developed!

junit tests fail

When I run mvn package or mvn install, some of the tests fail. The stack traces were looking for simplejpa.properties file in the classpath. I added the properties file to the classpath just to see what would happen, but more errors came up after that.

Failed tests:
testNoParameterReplacement(com.spaceprogram.simplejpa.query.SimpleDBQueryTests)
testSimpleParameterReplacement(com.spaceprogram.simplejpa.query.SimpleDBQueryTests)
testIntegerValueReplacement(com.spaceprogram.simplejpa.query.SimpleDBQueryTests)
testDateValueReplacement(com.spaceprogram.simplejpa.query.SimpleDBQueryTests)
testMultipleReplacements(com.spaceprogram.simplejpa.query.SimpleDBQueryTests)

Tests in error:
com.spaceprogram.simplejpa.CacheTests
com.spaceprogram.simplejpa.CacheTests
com.spaceprogram.simplejpa.DomainHelperTests
com.spaceprogram.simplejpa.DomainHelperTests
com.spaceprogram.simplejpa.PerformanceTests
com.spaceprogram.simplejpa.PerformanceTests
com.spaceprogram.simplejpa.PersistenceTests
com.spaceprogram.simplejpa.PersistenceTests
com.spaceprogram.simplejpa.SessionlessTests
com.spaceprogram.simplejpa.SessionlessTests
com.spaceprogram.simplejpa.StatsTests
com.spaceprogram.simplejpa.StatsTests
com.spaceprogram.simplejpa.UtilTests
com.spaceprogram.simplejpa.UtilTests

Tests run: 67, Failures: 5, Errors: 14, Skipped: 1

LazyList and Collections.sort() and Collections.reverse() behavior

Hi there,

I'm getting very inconsistent and buggy behavior when calling Collections.sort() and Collections.reverse() on the LazyLists returned by query.getResultList(). Basically, the lists are sometimes properly sorted and reversed and sometimes they are half sorted, not sorted in the right order, etc.

I couldn't narrow down the issue precisely but I assume it happens if the LazyList isn't fully populated. Couple questions:

  • Is there anyway to force the lazylist to be populated, or disable lazy loading altogether?
  • Is there any precautions I need to take for these lazy list to behave as normal lists?

Thanks!

Attribute en/decoding strategy of the EntityManager is not configuable

The decoding strategy used by the EntityManager to store integer or floats is not configurable and the default mechanism makes the content in the atrribute field pretty much non-interpretable.

Why not:

  1. Make the type serialization of attributes configurable
  2. Why did you not use the AWS en/decode tools? They are provided by com.amazonaws.services.simpledb.util.SimpleDBUtils.

Builds with Maven

From google code issue (http://code.google.com/p/simplejpa/issues/detail?id=10)

It would be nice if you supported building with maven. I attached a
reasonable one to this issue.

Also for extra credit, set up a sync with the central maven repo.
http://maven.apache.org/guides/mini/guide-central-repository-upload.html

pom.xml 

1.8 KB View Download
Comment 1 by [email protected], Aug 17, 2009
The lates svn checkout needs the attached pom --
pom.xml
2.0 KB View Download
Comment 2 by [email protected], Feb 8, 2010
There is a Google code project that helps you sync with Maven Central. See here for
help doing this in a Google code project:
http://code.google.com/p/google-maven-repository/wiki/ProjectSetup

Comment 3 by [email protected], Sep 23, 2010
And it would be nice if KittyCache also provided in Maven Central or included in the SimpleJPA jar.
Comment 4 by project member [email protected], Jan 28, 2011
I'd love to help with this issue - I've just got the latest from the trunk and would love to commit some updates to the pom - but how can I get commit rights?

I would heavily suggest we start using the release plugin to build and commit releases in the branches. Also the amazonaws reference is not to the latest version. and there are a few other ways the pom file can be cleaned up. I am happy to do any other work to get versions into the central repo also.
Comment 5 by project member [email protected], Feb 7, 2011
I've started reorganizing the builds. KittyCache and EHCache are now separated from the core source base. This allows things the build cleanly without any issues. I bumped a few of the dependencies and will sync the latest version of the AWS plugin if we rolled a new version out since last I checked. We have a sonatype account and will likely be leveraging that to get into the central maven repo.

In addition to sorting out the release plugin we also need to cleanup the unit tests. In the meantime send/attach and diffs for the maven build to this ticket.
Comment 6 by project member [email protected], Feb 7, 2011
Bumped the following dependencies to the latest stable versions.

commons-lang - 2.6
AWS - 1.1.5

Is simplejpa certified to run on AWS 1.2.6?

Is simplejpa certified to run on AWS 1.2.6? The pom files still reference a older version of AWS.

<dependency>
  <groupId>com.amazonaws</groupId>
  <artifactId>aws-java-sdk</artifactId>
  <version>1.1.8</version>
</dependency>    

Queries with keyword 'IN'

The AppendIn method of the QueryImpl class does not append commas in between values.

The following code should fix that:

private void appendIn(StringBuilder sb, String field, List params) {
sb.append("").append(field).append("");
sb.append(" ");
sb.append("IN");
sb.append(" (");
boolean quoteParam = true;
for(int i = 0; i < params.size(); i++){
if(i != 0){
sb.append(",");
}
sb.append("'").append(params.get(i)).append("'");
}
sb.append(")");
}

Add CriteriaBuilder support.

Add support for CriteriaBuilder to implementation. EntityManger should provide a getCriteriaBuilder() method.

Using 'order by' gives InvalidSortExpression

Order by seems to be broken.

Running a query like this:

Query q = em.createQuery("select e from SomeTable e where e.somefield = :somefield order by e.score desc");

Will send a query like this to Amazon:

[INFO ] com.amazonaws.request: Sending Request: POST http://sdb.amazonaws.com / Parameters: (ConsistentRead: true, Action: Select, Version: 2009-04-15, SelectExpression: select count(*) from SomeDomain-SomeTable where somefield = 'somevalue' order by score desc, )

Which gives this error:

[INFO ] com.amazonaws.request: Received error response: Status Code: 400, AWS Request ID:XXX, AWS Error Code: InvalidSortExpression, AWS Error Message: Invalid sort expression. The sort attribute must be present in at least one of the predicates, and the predicate cannot contain the is null operator.
javax.persistence.PersistenceException: Status Code: 400, AWS Request ID: XXX, AWS Error Code: InvalidSortExpression, AWS Error Message: Invalid sort expression. The sort attribute must be present in at least one of the predicates, and the predicate cannot contain the is null operator.
at com.spaceprogram.simplejpa.query.AbstractQuery.getResultList(AbstractQuery.java:216)
at com.spaceprogram.simplejpa.query.QueryImpl.getCount(QueryImpl.java:369)
at com.spaceprogram.simplejpa.LazyList.size(LazyList.java:75)

Running the exact same query without the 'order by e.score desc' clause works without error. I guess the error might have to do with passing the order by clause to AWS when doing a count.

I'm getting this issue both in the 1.6 snapshot and in the AWS SDK .jar.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.