romanb / jpa-nestedset Goto Github PK
View Code? Open in Web Editor NEWA NestedSet implementation for use with JPA(2)
A NestedSet implementation for use with JPA(2)
I've tried to use JPANestedset which seems great and perfectly respond to my need but Play! model uses long ID and NodeInfo int ID..... I'm not a Java GURU and I don't know workaround to inherit from Play model & implement NodeInfo in the same time ...
But, is an int ID enough ? Should not a long better suitable for this need ?
PS: great work & many thanks
PSPS: sorry for my english :-(
Pessimistic locking support of JPA 2 should be used to prevent tree corruption in concurrent scenarios. A lock on the root node of the tree being modified may be enough.
If you use the method Node.moveAsFirstChildOf(Node node) to move a node, the Node is moved as expected, however the node and databasefield 'level' is not modified accordingly.
JPQLException : If you specify the name of the entity the queries are not created correctly because it uses the name of the class.
I created a fork of the repository and I solved the problem
Example:
@entity(name="CAT")
public class Category implements NodeInfo {
@id @GeneratedValue
private int id;
private String name;
...
}
Exception Description: Error compiling the query [update Category n set n.lft = n.lft + ?1 where n.lft >= ?2 and n.rootId = ?4], line 1, column 0: Unknown entity type [Category].
at
...
org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.jaCaused by: Exception [EclipseLink-8037](Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Error compiling the query [update Category n set n.lft = n.lft + ?1 where n.lft >= ?2 and n.rootId = ?4], line 1, column 0: Unknown entity type [Category].
at org.eclipse.persistence.exceptions.JPQLException.entityTypeNotFound2(JPQLException.
at org.eclipse.persistence.internal.jpa.parsing.ModifyNode.resolveClass(ModifyNode.java:103)
...
I get an error when I use node.getDescendants():
org.hibernate.hql.internal.ast.QuerySyntaxException: expecting CLOSE, found '.' near line 1, column 125 [select generatedAlias0 from com.builder.ws.domain.ProductGroup as generatedAlias0 where ( ( cast(generatedAlias0.lft as java.lang.Number)>1 ) and ( cast(generatedAlias0.rgt as java.lang.Number)<6 ) ) and ( generatedAlias0.rootId=0 ) order by generatedAlias0.lft asc]
also I get an error when using Node.getParent():
org.hibernate.hql.internal.ast.QuerySyntaxException: expecting CLOSE, found '.' near line 1, column 127 [select generatedAlias0 from com.builder.ws.domain.ProductGroup as generatedAlias0 where ( ( ( cast(generatedAlias0.lft as java.lang.Number)>1 ) and ( cast(generatedAlias0.rgt as java.lang.Number)<8 ) ) and ( cast(generatedAlias0.level as java.lang.Number)<=1 ) ) and ( generatedAlias0.rootId=0 ) order by generatedAlias0.lft asc]
Node.addChild works however.
This repo needs a readme file with some quick-start guide, because now we need to dig into code to understand how to use it.
Hi,
When you call delete() method, it does not remove the Node from children/descendants of parent/ancestor nodes.
Cheers,
Guilherme Blanco
How I can move a child as a new root (on clear the child parent reference)?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.