我有以下实体:
同时也是这样:
当插入应用实体时,会显示以下错误:
@Entity
@Table(name="APLICACAO")
public class Aplicacao implements Serializable, Entidade {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="CD_APLICACAO")
private Long codigo;
@Column(name="NM_APLICACAO")
@NotNull
private String nome;
@ManyToOne
@JoinColumn(name="CD_GRUPO")
private GrupoAplicacao grupoAplicacao;
....
}
同时也是这样:
@Entity
@Table(name = "GRUPO_APLICACAO")
public class GrupoAplicacao implements Serializable, Entidade {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "CD_GRUPO")
private Long codigo;
@Column(name = "NM_GRUPO")
@NotNull
private String nome;
@OneToMany(mappedBy = "grupoAplicacao",fetch=FetchType.EAGER)
private List<Aplicacao> listaAplicacao;
@OneToMany(mappedBy = "grupoAplicacao",fetch=FetchType.EAGER)
private List<GrupoAplicacaoUsuario> listaGrupoAplicacaoUsuario;
....
}
我要调用HTML控制器"aplicacoesCreateController",代码如下:
<div class="col-xs-12" ng-controller="aplicacoesCreateController">
<form class="form-horizontal form-medium center" role="form" name="form" ng-submit="save()">
<div class="form-group">
<label for="nome" class="col-xs-4 control-label">Nome</label>
<div class="col-xs-8">
<input type="text" class="form-control input-sm" id="nome" placeholder="Nome" required ng-model="aplicacao.nome">
</div>
</div>
<div class="form-group">
<label for="nome" class="col-xs-4 control-label">Nome</label>
<div class="col-xs-8">
<select class="form-control" required ng-model="aplicacao.grupoAplicacao">
<option ng-repeat="grupo in grupos" value="{{ grupo }}">
{{ grupo.nome }}
</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-xs-offset-4 col-xs-8">
<button type="submit" class="btn btn-lg btn-size-md">Salvar</button>
</div>
</div>
</form>
</div>
我的控制器JavaScript代码:
app.controller('aplicacoesCreateController', ['$scope','aplicacoesService','$location','reloadService','gruposService',
function ($scope,aplicacoesService,$location,reloadService,gruposService) {
$scope.grupos = gruposService.list();
$scope.save = function () {
aplicacoesService.create($scope.aplicacao);
reloadService.on('#/aplicacoes');
};
}]);
并提供JavaScript服务:
app.factory('gruposService', ['$resource', function ($resource) {
return $resource('resources/grupo-aplicacao', {}, {
'list': { method: 'GET', isArray: true }
});
}]);
其他服务:
app.factory('aplicacoesService', ['$resource', function ($resource) {
return $resource('resources/aplicacao', {}, {
'list': { method: 'GET', isArray: true },
'create': { method: 'POST' }
});
}]);
当插入应用实体时,会显示以下错误:
Caused by: org.codehaus.jackson.map.JsonMappingException: Can not instantiate value of type [simple type, class br.com.techpeople.grape.entity.GrupoAplicacao] from JSON String; no single-String constructor/factory method (through reference chain: br.com.techpeople.grape.entity.Aplicacao["grupoAplicacao"])
你能帮我解决这个错误吗?