📄 example_weblog.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 "Exemple : application Weblog"#. Tag: title#: example_weblog.xml:32#, no-c-formatmsgid "Persistent Classes"msgstr "Classes persistantes"#. 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 """Les classes persistantes representent un weblog, et un article posté dans un ""weblog. Il seront modélisés comme une relation père/fils standard, mais nous ""allons utiliser un \"bag\" trié au lieu d'un 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 "Mappings Hibernate"#. Tag: para#: example_weblog.xml:49#, no-c-formatmsgid "The XML mappings should now be quite straightforward."msgstr "Le mapping XML doit maintenant être relativement simple à vos yeux."#. 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 "Code 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 """La classe suivante montre quelques utilisations que nous pouvons faire de ""ces classes."#. 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 + -