我正在尝试对数据库中的对象层次结构(实际上是域组)进行建模。我决定使用闭包表,这样我就可以在查询层次结构时获得高度灵活性。基本上,我的架构看起来像这样:
CREATE TABLE group (
id INT -- primary key
... -- other fields here
)
CREATE TABLE groupHierarchy (
idAncestor INT,
idGroup INT,
hierarchyLevel INT
)
Run Code Online (Sandbox Code Playgroud)
因此,当 id 为 1 的组包含 id 为 2 的组,而该组又包含 id 为 3 的组时,我需要在 groupHierarchy 表中包含以下行。
idAncestor idGroup hierarchyLevel
1 1 0
2 2 0
3 3 0
1 2 1
2 3 1
1 3 2
Run Code Online (Sandbox Code Playgroud)
我也可以接受没有 hierarchyLevels 为 0 的行(自引用)。
现在我想要一个映射到组表的 JPA 实体。我的问题是 - 管理 groupHierarchy 表的好方法是什么?
我已经考虑的是:
1)将组层次结构映射为元素集合,例如:
@ElementCollection
@JoinTable(name = …Run Code Online (Sandbox Code Playgroud) 我试图在Gulp任务中使用Wiredep在我的index.html文件中注入Bower依赖项.以下任务(没有Wiredep)运行正常.
gulp.task('build', ['copy', 'assets'], function(){
return gulp.src('app/index.html')
.pipe(inject(gulp.src(['dist/assets/js/*.js', 'dist/assets/css/*.css'], {read: false}), {relative: true}))
.pipe(gulp.dest('dist'));
});
Run Code Online (Sandbox Code Playgroud)
现在我尝试添加Wiredep:
var wiredep = require('wiredep');
gulp.task('build', ['copy', 'assets'], function(){
return gulp.src('app/index.html')
.pipe(wiredep())
.pipe(inject(gulp.src(['dist/assets/js/*.js', 'dist/assets/css/*.css'], {read: false}), {relative: true}))
.pipe(gulp.dest('dist'));
});
Run Code Online (Sandbox Code Playgroud)
结果如下:
[09:45:11] TypeError: dest.on is not a function
at DestroyableTransform.Readable.pipe (C:\GIT\myApp\myApp-front\node_module
s\gulp-debug\node_modules\through2\node_modules\readable-stream\lib\_stream_read
able.js:533:8)
at Gulp.<anonymous> (C:\GIT\myApp\myApp-front\gulpfile.js:38:6)
at module.exports (C:\GIT\myApp\myApp-front\node_modules\gulp\node_modules\
orchestrator\lib\runTask.js:34:7)
at Gulp.Orchestrator._runTask (C:\GIT\myApp\myApp-front\node_modules\gulp\n
ode_modules\orchestrator\index.js:273:3)
at Gulp.Orchestrator._runStep (C:\GIT\myApp\myApp-front\node_modules\gulp\n
ode_modules\orchestrator\index.js:214:10)
at C:\GIT\myApp\myApp-front\node_modules\gulp\node_modules\orchestrator\ind
ex.js:279:18
at finish (C:\GIT\myApp\myApp-front\node_modules\gulp\node_modules\orchestr
ator\lib\runTask.js:21:8)
at C:\GIT\myApp\myApp-front\node_modules\gulp\node_modules\orchestrator\lib
\runTask.js:52:4
at f (C:\GIT\myApp\myApp-front\node_modules\gulp\node_modules\orchestrator\
node_modules\end-of-stream\node_modules\once\once.js:17:25)
at …Run Code Online (Sandbox Code Playgroud)