Home > C#, Java > Compact Class Scrabble [Java Versus C#]

Compact Class Scrabble [Java Versus C#]


Berikut ini merupakan persamaan dan perbedaan dalam menggunakan CCHibernate:

  • Java meng-enkapsulasi attributenya dengan setter-getter, kita harus menggunakan set…(value) untuk memberikan value, dan get…() untuk mendapatkan nilai.
  • C# meng-enkapsulasi attributenya dengan setter-getter, kita cukup menggunakan persamaan sederhana untuk memberikan nilai, dan mendapatkan nilai.
    @Entity
    @Table(name = "language")
    public static class Language {

        @Id
        @GeneratedValue(strategy = javax.persistence.GenerationType.IDENTITY)
        private Long id;
        @Column(length = 32)
        private String name;

        public Long getId() {
            return id;
        }

        public void setId(Long id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }
    [Class(Table = "language")]
    public class Language
    {
        [Id(Name = "id")]
        [Generator(1, Class = "native")]
        public virtual int id { get; set; }

        [Property(Length = 32)]
        public virtual String name { get; set; }
    }

        CCDatabaseConfig config = new CCDatabaseConfig();
        config.setSupportedDatabase(SupportedDatabase.MySQL);
        config.setPassword("1234");
        config.setDatabase("compactClass");
            CCDatabaseConfig config = new CCDatabaseConfig();
            config.supportedDatabase = SupportedDatabase.MySQL;
            config.password = "1234";
            config.database = "compactClass";
        CCHibernate hibernate = new CCHibernate();
        hibernate.setProperty(config);
        hibernate.addAnnotatedClass(Language.class);
        hibernate.buildSessionFactory();
            CCHibernate hibernate = new CCHibernate();
            hibernate.setProperty(config);
            hibernate.addAnnotatedClass(Assembly.GetExecutingAssembly());
            hibernate.buildSessionFactory();
        Language language = new Language();
        language.setName("Compact Class on Java");
        hibernate.save(language);
            Language language = new Language();
            language.name = "Compact Class on C#";
            hibernate.save(language);
Categories: C#, Java Tags: , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: