Review

展开阅读全文
博主设置当前文章不允许评论。

Haiku Review

09-18

Haiku is an ancient form of Japanese poetry. A haiku is a three-line poem with seventeen syllables, where the first line must contain five syllables, the second line must contain seven syllables, and the third line must contain five syllables. The lines do not have to rhyme. Here is an example, where slashes separate the lines:nComputer programs/The bugs try to eat my code/I must not let them.nnYou must write a program that will review a haiku and check that each line contains the correct number of syllables.nnnInputnnThe input contains one or more lines, each of which contains a single haiku. A haiku will contain at least three words, and words will be separated by either a single space or a slash (`/'). Slashes also separate the three lines of a haiku, so each haiku will contain exactly two slashes. (The three lines of the haiku will be contained within one physical line of the file.) A haiku will contain only lowercase letters (`a'-`z'), forward slashes (`/'), and spaces, and will be no more than 200 characters long (not counting the end-of-line characters).nnThe haiku `e/o/i' signals the end of the input.nnEach haiku is guaranteed to contain three lines, and each line will contain at least one word. Your job is to determine whether each line has the correct number of syllables (5/7/5). For the purposes of this problem, every contiguous sequence of one or more vowels counts as one syllable, where the vowels are a, e, i, o, u, and y. Every word will contain at least one syllable. (Note that this method of counting syllables does not always agree with English conventions. In the second example below, your program must consider the word `code' to have two syllables because the `o' and the `e' are not consecutive. However, in English the `e' is silent and so `code' actually has only one syllable.)nnnOutputnnFor each haiku, output a single line that contains `1' if the first line has the wrong number of syllables, `2' if the second line has the wrong number of syllables, `3' if the third line has the wrong number of syllables, or `Y' if all three lines have the correct number of syllables. If the haiku is not correct, you must output the number of the first line that has the wrong number of syllables.nnnSample Inputnnhappy purple frog/eating bugs in the marshes/get indigestionncomputer programs/the bugs try to eat my code/i will not let themna e i o u/this is seven syllables/a e i o u yne/o/innnSample OutputnnYn2n3n 问答

Hibernate Review

07-23

Hibernate.cfg.xmlrnrnrnrnrnrnrn rnrn rn com.mysql.jdbc.Driverrn jdbc:mysql://localhost/hibernatern rootrn rootrnrn rn 1rnrn rn org.hibernate.dialect.MySQLDialectrnrn rn threadrnrn rn org.hibernate.cache.NoCacheProviderrnrn rn truern  truernrn rn updaternrn rn rn rnrnrnrnLog4j.xmlrnrn### direct log messages to stdout ###rnlog4j.appender.stdout=org.apache.log4j.ConsoleAppenderrnlog4j.appender.stdout.Target=System.outrnlog4j.appender.stdout.layout=org.apache.log4j.PatternLayoutrnlog4j.appender.stdout.layout.ConversionPattern=%dABSOLUTE %5p %c:%L - %m%nrnrn### direct messages to file hibernate.log ###rn#log4j.appender.file=org.apache.log4j.FileAppenderrn#log4j.appender.file.File=hibernate.logrn#log4j.appender.file.layout=org.apache.log4j.PatternLayoutrn#log4j.appender.file.layout.ConversionPattern=%dABSOLUTE %5p %c1:%L - %m%nrnrn### set log levels - for more verbose logging change 'info' to 'debug' ###rnrnlog4j.rootLogger=warn, stdoutrnrn#log4j.logger.org.hibernate=inforn#log4j.logger.org.hibernate=debugrnrn### log HQL query parser activityrn#log4j.logger.org.hibernate.hql.ast.AST=debugrnrn### log just the SQLrn#log4j.logger.org.hibernate.SQL=debugrnrn### log JDBC bind parameters ###rn#log4j.logger.org.hibernate.type=inforn#log4j.logger.org.hibernate.type=debugrnrn### log schema export/update ###rnlog4j.logger.org.hibernate.tool.hbm2ddl=debugrnrnrnSavernrnSessionFactory sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();rn Session session = sessionFactory.getCurrentSession();rn session.beginTransaction();rn session.save(t);rn session.getTransaction().commit();rnsessionFactory.close();rnrnList/Iteate compare, your should know the differencernrnrnSession session = sf.openSession();rn session.beginTransaction();rn Iterator topics = session.createQuery("from Topic").iterate();rn while(topics.hasNext()) rn System.out.println(topics.next().getTitle());rn rn rn Iterator topics2 = session.createQuery("from Topic").iterate();rn while(topics2.hasNext()) rn System.out.println(topics2.next().getTitle());rn rn rn rn session.getTransaction().commit();rn session.close();rnrnSession session = sf.openSession();rn session.beginTransaction();rn Iterator topics = session.createQuery("from Topic").list().iterator();rn while(topics.hasNext()) rn System.out.println(topics.next().getTitle());rn rn rn Iterator topics2 = session.createQuery("from Topic").list().iterator();rn while(topics2.hasNext()) rn System.out.println(topics2.next().getTitle());rn rn rn rn session.getTransaction().commit();rn session.close();rnrnBoolean mappingrnrnrnEnum mappingrn@Enumerated(EnumType.STRING)rnrnrnsession.clear();rn //把缓存中的teacher清除掉,注意,如果这里不写这行的话,将只发出一条select语句,原因是从缓存中直接读取,而如果写了的话,将rn //发出两条select语句(前提是teacher的id相同)rnrnTeacher t=(Teacher)session.load(Teacher.class, 1);rn //注意在没有写session.flush()的情况下,将输出几条update 语句rn t.setName("tt51");rn rn //session.flush();//强制进行同步rn rn t.setName("tttt52");rn rn ts.commit();rn //默认的情况下,在ts.commit()后会将数据库与缓存的对象进行同步rnrn 论坛

没有更多推荐了,返回首页