⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 example_weblog.po

📁 hibernate-distribution-3.3.1.GA-dist.zip源码
💻 PO
字号:
msgid ""msgstr """Project-Id-Version: PACKAGE VERSION\n""Report-Msgid-Bugs-To: http://bugs.kde.org\n""POT-Creation-Date: 2008-08-14 15:28+0000\n""PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n""Last-Translator: FULL NAME <EMAIL@ADDRESS>\n""Language-Team: LANGUAGE <LL@li.org>\n""MIME-Version: 1.0\n""Content-Type: text/plain; charset=UTF-8\n""Content-Transfer-Encoding: 8bit\n"#. Tag: title#: example_weblog.xml:29#, no-c-formatmsgid "Example: Weblog Application"msgstr "示例:Weblog 应用程序"#. Tag: title#: example_weblog.xml:32#, no-c-formatmsgid "Persistent Classes"msgstr "持久化类"#. Tag: para#: example_weblog.xml:34#, no-c-formatmsgid """The persistent classes represent a weblog, and an item posted in a weblog. ""They are to be modelled as a standard parent/child relationship, but we will ""use an ordered bag, instead of a set."msgstr """下面的持久化类表示一个weblog和在其中张贴的一个贴子。他们是标准的父/子关系模""型,但是我们会用一个有序包(ordered bag)而非集合(set)。"#. Tag: programlisting#: example_weblog.xml:40#, no-c-formatmsgid """<![CDATA[package eg;\n""\n""import java.util.List;\n""\n""public class Blog {\n""    private Long _id;\n""    private String _name;\n""    private List _items;\n""\n""    public Long getId() {\n""        return _id;\n""    }\n""    public List getItems() {\n""        return _items;\n""    }\n""    public String getName() {\n""        return _name;\n""    }\n""    public void setId(Long long1) {\n""        _id = long1;\n""    }\n""    public void setItems(List list) {\n""        _items = list;\n""    }\n""    public void setName(String string) {\n""        _name = string;\n""    }\n""}]]>"msgstr ""#. Tag: programlisting#: example_weblog.xml:42#, no-c-formatmsgid """<![CDATA[package eg;\n""\n""import java.text.DateFormat;\n""import java.util.Calendar;\n""\n""public class BlogItem {\n""    private Long _id;\n""    private Calendar _datetime;\n""    private String _text;\n""    private String _title;\n""    private Blog _blog;\n""\n""    public Blog getBlog() {\n""        return _blog;\n""    }\n""    public Calendar getDatetime() {\n""        return _datetime;\n""    }\n""    public Long getId() {\n""        return _id;\n""    }\n""    public String getText() {\n""        return _text;\n""    }\n""    public String getTitle() {\n""        return _title;\n""    }\n""    public void setBlog(Blog blog) {\n""        _blog = blog;\n""    }\n""    public void setDatetime(Calendar calendar) {\n""        _datetime = calendar;\n""    }\n""    public void setId(Long long1) {\n""        _id = long1;\n""    }\n""    public void setText(String string) {\n""        _text = string;\n""    }\n""    public void setTitle(String string) {\n""        _title = string;\n""    }\n""}]]>"msgstr ""#. Tag: title#: example_weblog.xml:47#, no-c-formatmsgid "Hibernate Mappings"msgstr "Hibernate 映射"#. Tag: para#: example_weblog.xml:49#, no-c-formatmsgid "The XML mappings should now be quite straightforward."msgstr "下列的XML映射应该是很直白的。"#. Tag: programlisting#: example_weblog.xml:53#, no-c-formatmsgid """<![CDATA[<?xml version=\"1.0\"?>\n""<!DOCTYPE hibernate-mapping PUBLIC\n""    \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n""    \"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd\">\n""\n""<hibernate-mapping package=\"eg\">\n""\n""    <class\n""        name=\"Blog\"\n""        table=\"BLOGS\">\n""\n""        <id\n""            name=\"id\"\n""            column=\"BLOG_ID\">\n""\n""            <generator class=\"native\"/>\n""\n""        </id>\n""\n""        <property\n""            name=\"name\"\n""            column=\"NAME\"\n""            not-null=\"true\"\n""            unique=\"true\"/>\n""\n""        <bag\n""            name=\"items\"\n""            inverse=\"true\"\n""            order-by=\"DATE_TIME\"\n""            cascade=\"all\">\n""\n""            <key column=\"BLOG_ID\"/>\n""            <one-to-many class=\"BlogItem\"/>\n""\n""        </bag>\n""\n""    </class>\n""\n""</hibernate-mapping>]]>"msgstr ""#. Tag: programlisting#: example_weblog.xml:55#, no-c-formatmsgid """<![CDATA[<?xml version=\"1.0\"?>\n""<!DOCTYPE hibernate-mapping PUBLIC\n""    \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n""    \"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd\">\n""\n""<hibernate-mapping package=\"eg\">\n""\n""    <class\n""        name=\"BlogItem\"\n""        table=\"BLOG_ITEMS\"\n""        dynamic-update=\"true\">\n""\n""        <id\n""            name=\"id\"\n""            column=\"BLOG_ITEM_ID\">\n""\n""            <generator class=\"native\"/>\n""\n""        </id>\n""\n""        <property\n""            name=\"title\"\n""            column=\"TITLE\"\n""            not-null=\"true\"/>\n""\n""        <property\n""            name=\"text\"\n""            column=\"TEXT\"\n""            not-null=\"true\"/>\n""\n""        <property\n""            name=\"datetime\"\n""            column=\"DATE_TIME\"\n""            not-null=\"true\"/>\n""\n""        <many-to-one\n""            name=\"blog\"\n""            column=\"BLOG_ID\"\n""            not-null=\"true\"/>\n""\n""    </class>\n""\n""</hibernate-mapping>]]>"msgstr ""#. Tag: title#: example_weblog.xml:60#, no-c-formatmsgid "Hibernate Code"msgstr "Hibernate 代码"#. Tag: para#: example_weblog.xml:62#, no-c-formatmsgid """The following class demonstrates some of the kinds of things we can do with ""these classes, using Hibernate."msgstr "下面的类演示了我们可以使用Hibernate对这些类进行的一些操作。"#. Tag: programlisting#: example_weblog.xml:67#, no-c-formatmsgid """<![CDATA[package eg;\n""\n""import java.util.ArrayList;\n""import java.util.Calendar;\n""import java.util.Iterator;\n""import java.util.List;\n""\n""import org.hibernate.HibernateException;\n""import org.hibernate.Query;\n""import org.hibernate.Session;\n""import org.hibernate.SessionFactory;\n""import org.hibernate.Transaction;\n""import org.hibernate.cfg.Configuration;\n""import org.hibernate.tool.hbm2ddl.SchemaExport;\n""\n""public class BlogMain {\n""    \n""    private SessionFactory _sessions;\n""    \n""    public void configure() throws HibernateException {\n""        _sessions = new Configuration()\n""            .addClass(Blog.class)\n""            .addClass(BlogItem.class)\n""            .buildSessionFactory();\n""    }\n""    \n""    public void exportTables() throws HibernateException {\n""        Configuration cfg = new Configuration()\n""            .addClass(Blog.class)\n""            .addClass(BlogItem.class);\n""        new SchemaExport(cfg).create(true, true);\n""    }\n""    \n""    public Blog createBlog(String name) throws HibernateException {\n""        \n""        Blog blog = new Blog();\n""        blog.setName(name);\n""        blog.setItems( new ArrayList() );\n""        \n""        Session session = _sessions.openSession();\n""        Transaction tx = null;\n""        try {\n""            tx = session.beginTransaction();\n""            session.persist(blog);\n""            tx.commit();\n""        }\n""        catch (HibernateException he) {\n""            if (tx!=null) tx.rollback();\n""            throw he;\n""        }\n""        finally {\n""            session.close();\n""        }\n""        return blog;\n""    }\n""    \n""    public BlogItem createBlogItem(Blog blog, String title, String text)\n""                        throws HibernateException {\n""        \n""        BlogItem item = new BlogItem();\n""        item.setTitle(title);\n""        item.setText(text);\n""        item.setBlog(blog);\n""        item.setDatetime( Calendar.getInstance() );\n""        blog.getItems().add(item);\n""        \n""        Session session = _sessions.openSession();\n""        Transaction tx = null;\n""        try {\n""            tx = session.beginTransaction();\n""            session.update(blog);\n""            tx.commit();\n""        }\n""        catch (HibernateException he) {\n""            if (tx!=null) tx.rollback();\n""            throw he;\n""        }\n""        finally {\n""            session.close();\n""        }\n""        return item;\n""    }\n""    \n""    public BlogItem createBlogItem(Long blogid, String title, String text)\n""                        throws HibernateException {\n""        \n""        BlogItem item = new BlogItem();\n""        item.setTitle(title);\n""        item.setText(text);\n""        item.setDatetime( Calendar.getInstance() );\n""        \n""        Session session = _sessions.openSession();\n""        Transaction tx = null;\n""        try {\n""            tx = session.beginTransaction();\n""            Blog blog = (Blog) session.load(Blog.class, blogid);\n""            item.setBlog(blog);\n""            blog.getItems().add(item);\n""            tx.commit();\n""        }\n""        catch (HibernateException he) {\n""            if (tx!=null) tx.rollback();\n""            throw he;\n""        }\n""        finally {\n""            session.close();\n""        }\n""        return item;\n""    }\n""    \n""    public void updateBlogItem(BlogItem item, String text)\n""                    throws HibernateException {\n""        \n""        item.setText(text);\n""        \n""        Session session = _sessions.openSession();\n""        Transaction tx = null;\n""        try {\n""            tx = session.beginTransaction();\n""            session.update(item);\n""            tx.commit();\n""        }\n""        catch (HibernateException he) {\n""            if (tx!=null) tx.rollback();\n""            throw he;\n""        }\n""        finally {\n""            session.close();\n""        }\n""    }\n""    \n""    public void updateBlogItem(Long itemid, String text)\n""                    throws HibernateException {\n""    \n""        Session session = _sessions.openSession();\n""        Transaction tx = null;\n""        try {\n""            tx = session.beginTransaction();\n""            BlogItem item = (BlogItem) session.load(BlogItem.class, ""itemid);\n""            item.setText(text);\n""            tx.commit();\n""        }\n""        catch (HibernateException he) {\n""            if (tx!=null) tx.rollback();\n""            throw he;\n""        }\n""        finally {\n""            session.close();\n""        }\n""    }\n""    \n""    public List listAllBlogNamesAndItemCounts(int max)\n""                    throws HibernateException {\n""        \n""        Session session = _sessions.openSession();\n""        Transaction tx = null;\n""        List result = null;\n""        try {\n""            tx = session.beginTransaction();\n""            Query q = session.createQuery(\n""                \"select blog.id, blog.name, count(blogItem) \" +\n""                \"from Blog as blog \" +\n""                \"left outer join blog.items as blogItem \" +\n""                \"group by blog.name, blog.id \" +\n""                \"order by max(blogItem.datetime)\"\n""            );\n""            q.setMaxResults(max);\n""            result = q.list();\n""            tx.commit();\n""        }\n""        catch (HibernateException he) {\n""            if (tx!=null) tx.rollback();\n""            throw he;\n""        }\n""        finally {\n""            session.close();\n""        }\n""        return result;\n""    }\n""    \n""    public Blog getBlogAndAllItems(Long blogid)\n""                    throws HibernateException {\n""        \n""        Session session = _sessions.openSession();\n""        Transaction tx = null;\n""        Blog blog = null;\n""        try {\n""            tx = session.beginTransaction();\n""            Query q = session.createQuery(\n""                \"from Blog as blog \" +\n""                \"left outer join fetch blog.items \" +\n""                \"where blog.id = :blogid\"\n""            );\n""            q.setParameter(\"blogid\", blogid);\n""            blog  = (Blog) q.uniqueResult();\n""            tx.commit();\n""        }\n""        catch (HibernateException he) {\n""            if (tx!=null) tx.rollback();\n""            throw he;\n""        }\n""        finally {\n""            session.close();\n""        }\n""        return blog;\n""    }\n""    \n""    public List listBlogsAndRecentItems() throws HibernateException {\n""        \n""        Session session = _sessions.openSession();\n""        Transaction tx = null;\n""        List result = null;\n""        try {\n""            tx = session.beginTransaction();\n""            Query q = session.createQuery(\n""                \"from Blog as blog \" +\n""                \"inner join blog.items as blogItem \" +\n""                \"where blogItem.datetime > :minDate\"\n""            );\n""\n""            Calendar cal = Calendar.getInstance();\n""            cal.roll(Calendar.MONTH, false);\n""            q.setCalendar(\"minDate\", cal);\n""            \n""            result = q.list();\n""            tx.commit();\n""        }\n""        catch (HibernateException he) {\n""            if (tx!=null) tx.rollback();\n""            throw he;\n""        }\n""        finally {\n""            session.close();\n""        }\n""        return result;\n""    }\n""}]]>"msgstr ""

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -