简体   繁体   English

在NHibernate中插入数据但对标识符不感兴趣

[英]Inserting data in NHibernate but not interested in identifier

I'm getting data from a webserver and insert them in my PostgreSQL database. 我从网络服务器获取数据,并将其插入到PostgreSQL数据库中。 My table has an id as serial , which is an auto-increment value handled by a sequence in PostgreSQL. 我的表的id为serial ,这是由PostgreSQL中的序列处理的自动增量值。

I'm just inserting data and don't do anything with the data after that point. 我只是插入数据,此后不对数据做任何事情。 So I'm not interested in the value of the ID. 因此,我对ID的值不感兴趣。 I see that NHibernate is calling select nextval for every insert. 我看到NHibernate为每个插入都调用select nextval How to tell NHibernate it is not necessary? 怎么告诉NHibernate没有必要? It just needs to send an insert-statement and move on. 它只需要发送一个插入语句并继续。

In my xml I have: 在我的xml中,我有:

<id name="Id" column="id">
  <generator class="native">
    <param name="sequence">id_seq</param>
  </generator>
</id>

I'm using this xml/class in other parts as well and then I get the data and then I do need the value of id. 我也在其他部分也使用了这个xml / class,然后获取数据,然后确实需要id的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM