我有一个图像备份,我恢复到MS SQL服务器2016.我有一个实体声明其ID如下:
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@XmlID
@XmlElement
@XmlJavaTypeAdapter(IntToStringXmlAdapter.class)
private Integer id;
Run Code Online (Sandbox Code Playgroud)
当我保存我收到的实体时:
Hibernate: select next_val as id_val from hibernate_sequence with (updlock, rowlock) 2018-02-28 22:05:41.935
ERROR 18152 --- [nio-8080-exec-6] o.hibernate.id.enhanced.TableStructure : could not read a hi value com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'hibernate_sequence'.
......
2018-02-28 22:05:41.942 WARN 18152 --- [nio-8080-exec-6] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 208, SQLState: S0002
2018-02-28 22:05:41.942 ERROR 18152 --- [nio-8080-exec-6] o.h.engine.jdbc.spi.SqlExceptionHelper : Invalid object name 'hibernate_sequence'.
Run Code Online (Sandbox Code Playgroud)
我已经手动创建了SQL服务器的序列,并确保它通过SSMS存在.
CREATE SEQUENCE hibernate_sequence
AS INTEGER
START WITH 1
INCREMENT BY 1 …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Angular 5 在选择选项中设置默认值。我已阅读有关 [compareWith] 的内容,但它似乎没有帮助。这是代码:
我的列举:
export enum EncryptionProtocol {
NONE,
SSL,
TLS }
Run Code Online (Sandbox Code Playgroud)
我的配置模型
export class Config implements BaseEntity {
constructor(
public id?: number,
...
public encryptionProtocol?: EncryptionProtocol,
...
) {
}
}
Run Code Online (Sandbox Code Playgroud)
我的HTML:
<div class="form-group">
<label class="form-control-label" for="field_encryptionProtocol">Encryption Protocol</label>
<select [compareWith]="compareFn" class="form-control" name="encryptionProtocol" [(ngModel)]="config.encryptionProtocol"
id="field_encryptionProtocol">
<option *ngFor="let encryptionProtocol of encryptionProtocolKeys()" [ngValue]="encryptionProtocol">
{{encryptionProtocol}}
</option>
</select>
</div>
Run Code Online (Sandbox Code Playgroud)
编辑:我的TS:
...
encryptionProtocols = EncryptionProtocol;
encryptionProtocolKeys() : Array<string> {
var keys = Object.keys(this.encryptionProtocols);
return keys.slice(keys.length / 2);
}
...
compareFn(c1: EncryptionProtocol, c2: …Run Code Online (Sandbox Code Playgroud) 我在 Config 和 ConfigHeaders 之间有一对多的关系。这是配置映射器:
@Mapper(componentModel = "spring", uses = {UserMapper.class, ConfigHeadersMapper.class})
public interface ConfigMapper extends EntityMapper<ConfigDTO, Config> {
@Mapping(source = "user.id", target = "userId")
ConfigDTO toDto(Config config);
@Mapping(source = "userId", target = "user")
@Mapping(target = "messages", ignore = true)
Config toEntity(ConfigDTO configDTO);
default Config fromId(Long id) {
if (id == null) {
return null;
}
Config config = new Config();
config.setId(id);
return config;
}
}
Run Code Online (Sandbox Code Playgroud)
这是 ConfigHeadersMapper:
@Mapper(componentModel = "spring", uses = {ConfigMapper.class})
public interface ConfigHeadersMapper extends EntityMapper<ConfigHeadersDTO, ConfigHeaders> …Run Code Online (Sandbox Code Playgroud)