Skip to content

DatabaseSelection is not allways used #2234

Closed
@VladoKuruc

Description

@VladoKuruc

After upgrade to SDN 6.1.0 I have Issue with DatabaseSelection.

I use an existing database for unit tests, so I do not create a database in them. I just need to clean up the data at the beginning of the transaction and with the rollback at the end so that testing does not affect the existing data.

In version 6.0.x, I had to use the .in(databaseName) clause.

neo4jClient.query("MATCH (n) DETACH DELETE n").in("neo4jtest").run();

DatabaseSelectionProvider is now available in version 6.1.x in neo4jClient, so it would be nice not to use it.
In this case, an error occurs.

java.lang.IllegalStateException: There is already an ongoing Spring transaction for 'neo4jtest', but you request the default database

However, the same error occurs in the case of a more complex mapping during repository.save () in a transaction where I cannot influence it.
Take a look at the attached unittest where I use the modified AltHobby class. I added two properties there.

DatabaseSelectionProviderIT.java.txt

	@Relationship(type = "CHILD", direction = Relationship.Direction.INCOMING)
	private List<AltHobby> memberOf = new ArrayList<>();

	@Relationship(type = "CHILD", direction = Relationship.Direction.OUTGOING)
	private List<AltHobby> childs = new ArrayList<>(); 

	public List<AltHobby> getMemberOf() {
		return memberOf;
	}
	
	public List<AltHobby> getChilds() {
		return childs;
	} 

Thank for investigation.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions