Full Error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Association references unmapped class: java.util.List
Here are my Domain classes:
class File implements Serializable {
String path;
String name;
public File(String path, String name) {
this.path = path;
this.name = name;
}
}
class Directory extends File {
List files = [];
public Directory(String path, String name) {
super(path, name);
}
}
Here is my DirectoryService:
@Transactional
class DirectoryService {
def fetchDirectory(String path) {
java.io.File dir = new Path(path);
java.io.File[] files = dir.listFiles();
Directory pdirectory = new Directory(path, dir.getName());
List list = [];
for(java.io.File file : files) {
File pfile = new File(path, file.getName());
list.add(pfile);
}
pdirectory.files = list;
return pdirectory;
}
}
The problem occurs because I have a List files = []
in Directory model class.
I don't even understand the problem to be able to find a solution. Why does Grails not allow me to have list in models? And if it is not actually allowed, I want to know how to make it work.
In my application I have many models with datasources that are not databases; and in this case, the SQL relationship equivalent is "Directory hasMany File." Also Directory itself is a subset of File.
static hasMany = [files: File]
instead? I think it needs to know a domain type for the collection/relationship. – Todd W CroneFile
? – GasimList<File> files = []
– defectus