component example - 3.5 of 4

本文介绍了如何利用NHibernate框架,通过XML映射文件定义Staff类及其组件,实现数据持久化操作。具体展示了如何定义类、属性、组件,并通过代码示例演示了映射配置与数据操作的基本流程。
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="TstDBConnection.Entities"
                   assembly="TstDBConnection">
  <class name="Staff" table="Staff">
    <id name="Id" column="Id">
      <generator class="guid.comb"/>
    </id>
    <property name="Title" column="Title"></property>
    <component name="Name" class="Name">
      <property name="FirstName" column="FirstName"></property>
      <property name="LastName" column="LastName"></property>
    </component>
  </class>
</hibernate-mapping>
namespace TstDBConnection.Entities
{
    public class Name
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }
}
namespace TstDBConnection.Entities
{
    public class Staff
    {
        public virtual Guid Id { get; set; }
        public virtual Name Name { get; set; }
        public virtual string Title { get; set; }
    }
}
        public static void TestComponentMapping(ISessionFactory sessionFactory)
        {
            using (ISession session = sessionFactory.OpenSession())
            {
                Name name = new Name() { FirstName = "John", LastName = "Doe" };
                Staff emp = new Staff() { Name = name, Title = "System Developer" };
                session.Save(emp);
                session.Flush();

                var query = from employee in session.Query<Staff>() select employee;
                IList<Staff> employees = query.ToList();
            }
        }
        static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure(); // log4net
            Configuration configuration = new Configuration();
            configuration.Configure();
            ISessionFactory sessionFactory = configuration.BuildSessionFactory();

            TestComponentMapping(sessionFactory);

            sessionFactory.Close();
        }

转载于:https://www.cnblogs.com/webglcn/archive/2012/09/06/2673445.html

CMake Error at D:/ESP-IDF/Espressif/frameworks/esp-idf-v5.3.2/tools/cmake/component.cmake:155 (message): Directory &#39;D:/ESP-IDF/project/xiaozhi-esp32-main/managed_components/lvgl__lvgl&#39; does not contain a component. -----------------------END OF ERROR----------------------- -- Configuring incomplete, errors occurred! ---------------------------ERROR-------------------------- Call Stack (most recent call first): D:/ESP-IDF/Espressif/frameworks/esp-idf-v5.3.2/tools/cmake/build.cmake:258 (__component_add) build/managed_components_list.temp.cmake:45 (idf_build_component) D:/ESP-IDF/Espressif/frameworks/esp-idf-v5.3.2/tools/cmake/build.cmake:555 (include) D:/ESP-IDF/Espressif/frameworks/esp-idf-v5.3.2/tools/cmake/project.cmake:710 (idf_build_process) CMakeLists.txt:13 (project) -----------------------END OF ERROR----------------------- ---------------------------ERROR-------------------------- cmake failed with exit code 1, output of the command is in the D:\ESP-IDF\project\xiaozhi-esp32-main\build\log\idf_py_stderr_output_1572 and D:\ESP-IDF\project\xiaozhi-esp32-main\build\log\idf_py_stdout_output_1572 -----------------------END OF ERROR----------------------- ---------------------------ERROR-------------------------- SDK Configuration editor confserver process exited with code: 2 -----------------------END OF ERROR----------------------- [/SDK Configuration Editor] [Serial port] No serial ports found {} Directory &#39;D:\ESP-IDF\project\xiaozhi-esp32-main\build&#39; doesn&#39;t seem to be a CMake build directory. Refusing to automatically delete files in this directory. Delete the directory manually to &#39;clean&#39; it. Adding "set-target"&#39;s dependency "fullclean" to list of commands with default set of options. Executing action: fullclean Failed to set target esp32c3: non zero exit code 2 Directory &#39;D:\ESP-IDF\project\xiaozhi-esp32-main\build&#39; doesn&#39;t seem to be a CMake build directory. Refusing to automatically delete files in this directory. Delete the dir
04-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值